Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How do I reference a directory for a file in VBA that is different

I have been successful in writing code that allows me to print a worksheet
within my workbook and then open up a Word document and print it as well. I
basicly cut and pasted VBA from suggestions by those of you that use this
discussion group. The Word document is located on my harddrive in the same
subdirectory as my Excel workbook. This happens to be my C:\ drive. I use
this same workbook file at work where the drive is F:\. Is there a way of
referencing the document file without the directory drive so that it just
assumes that it resides in the same subdirectory as the Excel file that is
executing the macro? What I have been doing, which I know is rediculous, is
changing the VBA reference drive based on the computer that I am using. Any
help with this would be greatly appreciated. Thanks, Steve
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default How do I reference a directory for a file in VBA that is different

You could put in an input box asking for the drive to use. Something
like:

DriveLetter = InputBox("Please enter a drive letter")

Then use that in your code when you determine the address.

  #3   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default How do I reference a directory for a file in VBA that is different

Thisworkbook.Path & Application.PathSeparator & "Yourfilename"



"SFGiants Fan" wrote:

I have been successful in writing code that allows me to print a worksheet
within my workbook and then open up a Word document and print it as well. I
basicly cut and pasted VBA from suggestions by those of you that use this
discussion group. The Word document is located on my harddrive in the same
subdirectory as my Excel workbook. This happens to be my C:\ drive. I use
this same workbook file at work where the drive is F:\. Is there a way of
referencing the document file without the directory drive so that it just
assumes that it resides in the same subdirectory as the Excel file that is
executing the macro? What I have been doing, which I know is rediculous, is
changing the VBA reference drive based on the computer that I am using. Any
help with this would be greatly appreciated. Thanks, Steve

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cell reference to make a directory path Dan Deschambault Excel Worksheet Functions 10 July 25th 07 07:25 PM
file save error: the file or directory cannot be created dublg Excel Discussion (Misc queries) 1 September 25th 06 07:07 PM
Excel should let me sort the file directory when saving a file Beanee70 Excel Discussion (Misc queries) 0 March 14th 06 07:03 AM
Combine all text file in directory into one file. Rich[_19_] Excel Programming 8 January 21st 04 04:09 PM
get path - save new file - same sub-directory as existing file tegger Excel Programming 2 October 21st 03 10:45 AM


All times are GMT +1. The time now is 12:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"