ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Open File Location (https://www.excelbanter.com/excel-programming/299317-open-file-location.html)

properties

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"





cucchiaino

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"




Bob Phillips[_6_]

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"







cucchiaino

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!!



properties

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"






Chip Pearson

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"









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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com