Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Open File Location

How can I rewrite this code to open a file named "invoice", in case I move
the workbook to another directory.

T.I.A.



Workbooks.OpenText Filename:= _
"C:\Documents and Settings\Owner\My
Documents\\Project\Summary\Test_Macro\invoice"




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Open File Location

properties wrote:
How can I rewrite this code to open a file named "invoice", in case I
move the workbook to another directory.

Workbooks.OpenText Filename:= _
"C:\Documents and Settings\Owner\My
Documents\\Project\Summary\Test_Macro\invoice"


Workbooks.OpenText Filename:= _
"C:\newdirectory\invoice"



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Open File Location

You either need to
- know the directory name
- get the path of the activeworkbook
- get the path of thisworkbook
- use GetOpenFilename to browse for the file.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"properties" wrote in message
...
How can I rewrite this code to open a file named "invoice", in case I move
the workbook to another directory.

T.I.A.



Workbooks.OpenText Filename:= _
"C:\Documents and Settings\Owner\My
Documents\\Project\Summary\Test_Macro\invoice"






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Open File Location

cucchiaino wrote:
properties wrote:
How can I rewrite this code to open a file named "invoice", in case I
move the workbook to another directory.

Workbooks.OpenText Filename:= _
"C:\Documents and Settings\Owner\My
Documents\\Project\Summary\Test_Macro\invoice"


Workbooks.OpenText Filename:= _
"C:\newdirectory\invoice"



Oops! Move you the workbook?

Not rewrite!!


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Open File Location

Sorry I didn't make my question clear. I want to write this code so that
regardless of where I put this workbook it will look to open the file in the
directory where the workbook exists.



"cucchiaino" wrote in message
...
properties wrote:
How can I rewrite this code to open a file named "invoice", in case I
move the workbook to another directory.

Workbooks.OpenText Filename:= _
"C:\Documents and Settings\Owner\My
Documents\\Project\Summary\Test_Macro\invoice"


Workbooks.OpenText Filename:= _
"C:\newdirectory\invoice"







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Open File Location

Use something like

Workbooks.Open ThisWorkbook.Path & "\Invoice.xls"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"properties" wrote in message
...
Sorry I didn't make my question clear. I want to write this

code so that
regardless of where I put this workbook it will look to open

the file in the
directory where the workbook exists.



"cucchiaino" wrote in message
...
properties wrote:
How can I rewrite this code to open a file named "invoice",

in case I
move the workbook to another directory.

Workbooks.OpenText Filename:= _
"C:\Documents and Settings\Owner\My
Documents\\Project\Summary\Test_Macro\invoice"


Workbooks.OpenText Filename:= _
"C:\newdirectory\invoice"







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
Excel will not open in default file location Roger Chapman Excel Discussion (Misc queries) 2 December 8th 10 04:58 PM
Open Last Modified File form Location Kam Excel Discussion (Misc queries) 4 December 30th 09 05:47 PM
VBA to ask for file location and use to open DB Brian Excel Worksheet Functions 4 May 15th 09 03:36 PM
Open File from FTP Location Bricol Excel Discussion (Misc queries) 3 January 9th 08 02:58 PM
Open From Read-Only Location ? Blewyn Excel Discussion (Misc queries) 3 December 17th 06 04:18 PM


All times are GMT +1. The time now is 10:00 PM.

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

About Us

"It's about Microsoft Excel"