Open File Location

  • Thread starter Thread starter properties
  • Start date Start date
P

properties

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"
 
properties said:
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"
 
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)
 
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.
 
Use something like

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


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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top