Find WkBk Path, Then use this path to open another WkBk in Sub
Thanks Dave, that worked a charm, but I simplified it slightly for my needs.
Workbooks.Open (ThisWorkbook.Path & "\Data\Book2.xls")
Cheers. I appreciate it. :-)
"Dave Peterson" wrote:
thisworkbook.path
will not include the filename.
It'll return something like:
C:\Program Files\Test\MyProgram
So maybe you could use:
Dim myFileName as string
dim wkbk2 as workbook
myfilename = thisworkbook.path & "\data\book2.xls"
set wkbk2 = workbooks.open(filename:=myfilename)
dim wrote:
Thank GS,
So If I put into my auto_open macro:
Location = (ThisWorkbook.Path)
Where the path is C:\Program Files\Test\MyProgram\Book1.xls
How do I then use the variable 'Location' to open the workbook Book2.xls in
C:\Program Files\Test\MyProgram\Data\. Something like:
Workbooks.Open ($ Location $ "\" Data\Book2.xls)
??? Thanks for any more advice?
"Gary''s Student" wrote:
Sub WhereAmI()
MsgBox (ThisWorkbook.Path)
End Sub
--
Gary''s Student - gsnu200781
--
Dave Peterson
|