ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Open workbook in user-defined folder (https://www.excelbanter.com/excel-programming/338755-open-workbook-user-defined-folder.html)

pdberger

Open workbook in user-defined folder
 
I've written a set of two workbooks for use by many different people.
"Instrument Panel User Data.xls" calls information out of "Instrument Panel
Reference Data.xls".
I don't know where each user will store these two files but I want to set
things up so that, as long as they're in the same folder, the 'User Data'
will find and open 'Reference Data'.

My code don't work! Here it is:

Private Sub Workbook_Open()
Dim File_Path As String
Dim File_Name As String

File_Path = ThisWorkbook.Path
File_Name = File_Path + "Instrument Panel Reference Data.xls"
Workbooks.Open Filename:="File_Name"


End Sub

What am I doing wrong? Do I have to slit my wrists? Say it ain't so!

Doug Glancy

Open workbook in user-defined folder
 
pdberger,

It ain't so! Untested, but I think this will do it:

File_Name = File_Path & "\" & "Instrument Panel Reference Data.xls"

hth,

Doug

"pdberger" wrote in message
...
I've written a set of two workbooks for use by many different people.
"Instrument Panel User Data.xls" calls information out of "Instrument

Panel
Reference Data.xls".
I don't know where each user will store these two files but I want to set
things up so that, as long as they're in the same folder, the 'User Data'
will find and open 'Reference Data'.

My code don't work! Here it is:

Private Sub Workbook_Open()
Dim File_Path As String
Dim File_Name As String

File_Path = ThisWorkbook.Path
File_Name = File_Path + "Instrument Panel Reference Data.xls"
Workbooks.Open Filename:="File_Name"


End Sub

What am I doing wrong? Do I have to slit my wrists? Say it ain't so!




pdberger

Open workbook in user-defined folder
 
Doug -- It still may be so! I continue to get a Run-time error '1004' .
The message reads:

"'File_Name.xls' could not be found. Check the spelling of the file name,
and verify that the location is correct."

I believe both of those two possible problems to be OK. I tried removing
the '.xls' from the 'File_Name =' statement.

Thanks anyway for your help, and thanks in advance to anyone else who offers
advice.

"Doug Glancy" wrote:

pdberger,

It ain't so! Untested, but I think this will do it:

File_Name = File_Path & "\" & "Instrument Panel Reference Data.xls"

hth,

Doug

"pdberger" wrote in message
...
I've written a set of two workbooks for use by many different people.
"Instrument Panel User Data.xls" calls information out of "Instrument

Panel
Reference Data.xls".
I don't know where each user will store these two files but I want to set
things up so that, as long as they're in the same folder, the 'User Data'
will find and open 'Reference Data'.

My code don't work! Here it is:

Private Sub Workbook_Open()
Dim File_Path As String
Dim File_Name As String

File_Path = ThisWorkbook.Path
File_Name = File_Path + "Instrument Panel Reference Data.xls"
Workbooks.Open Filename:="File_Name"


End Sub

What am I doing wrong? Do I have to slit my wrists? Say it ain't so!





Doug Glancy

Open workbook in user-defined folder
 
pdberger,

Change the line:
Workbooks.Open Filename:="File_Name"
to:
Workbooks.Open Filename:=File_Name

By putting it in quotes, you were telling it that Filename equals "FileName"
not "Instrument ..."

hth,

Doug

"pdberger" wrote in message
...
Doug -- It still may be so! I continue to get a Run-time error '1004' .
The message reads:

"'File_Name.xls' could not be found. Check the spelling of the file name,
and verify that the location is correct."

I believe both of those two possible problems to be OK. I tried removing
the '.xls' from the 'File_Name =' statement.

Thanks anyway for your help, and thanks in advance to anyone else who

offers
advice.

"Doug Glancy" wrote:

pdberger,

It ain't so! Untested, but I think this will do it:

File_Name = File_Path & "\" & "Instrument Panel Reference Data.xls"

hth,

Doug

"pdberger" wrote in message
...
I've written a set of two workbooks for use by many different people.
"Instrument Panel User Data.xls" calls information out of "Instrument

Panel
Reference Data.xls".
I don't know where each user will store these two files but I want to

set
things up so that, as long as they're in the same folder, the 'User

Data'
will find and open 'Reference Data'.

My code don't work! Here it is:

Private Sub Workbook_Open()
Dim File_Path As String
Dim File_Name As String

File_Path = ThisWorkbook.Path
File_Name = File_Path + "Instrument Panel Reference Data.xls"
Workbooks.Open Filename:="File_Name"


End Sub

What am I doing wrong? Do I have to slit my wrists? Say it ain't so!







pdberger

Open workbook in user-defined folder
 
Doug --

You dood it, dude! Muy goodo (as they say in Spanish)!

Thanks for your help!

Peter

"Doug Glancy" wrote:

pdberger,

Change the line:
Workbooks.Open Filename:="File_Name"
to:
Workbooks.Open Filename:=File_Name

By putting it in quotes, you were telling it that Filename equals "FileName"
not "Instrument ..."

hth,

Doug

"pdberger" wrote in message
...
Doug -- It still may be so! I continue to get a Run-time error '1004' .
The message reads:

"'File_Name.xls' could not be found. Check the spelling of the file name,
and verify that the location is correct."

I believe both of those two possible problems to be OK. I tried removing
the '.xls' from the 'File_Name =' statement.

Thanks anyway for your help, and thanks in advance to anyone else who

offers
advice.

"Doug Glancy" wrote:

pdberger,

It ain't so! Untested, but I think this will do it:

File_Name = File_Path & "\" & "Instrument Panel Reference Data.xls"

hth,

Doug

"pdberger" wrote in message
...
I've written a set of two workbooks for use by many different people.
"Instrument Panel User Data.xls" calls information out of "Instrument
Panel
Reference Data.xls".
I don't know where each user will store these two files but I want to

set
things up so that, as long as they're in the same folder, the 'User

Data'
will find and open 'Reference Data'.

My code don't work! Here it is:

Private Sub Workbook_Open()
Dim File_Path As String
Dim File_Name As String

File_Path = ThisWorkbook.Path
File_Name = File_Path + "Instrument Panel Reference Data.xls"
Workbooks.Open Filename:="File_Name"


End Sub

What am I doing wrong? Do I have to slit my wrists? Say it ain't so!








All times are GMT +1. The time now is 06:37 AM.

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