ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Open files in the same directory (https://www.excelbanter.com/excel-discussion-misc-queries/143487-open-files-same-directory.html)

houghi

Open files in the same directory
 
At this moment I use something like:

Set RptWkbk = Workbooks.Open(Filename:="Y:\ALL_USERS\Username\St atistics\Department 01\Individual Report.XLS")
I have another file open in the same directory that does the above and
that works wonders.

However I would like it to point to the file with the name "Individual
Report.XLS", but without the drive and such, so I can send it to people
who are on a different machine.

I tried the following, but it did not work:
Set RptWkbk = Workbooks.Open(Filename:="Individual Report.XLS")

Probably prety basic stuff, but I can't seem to figure it out.

houghi
--
Let's not be too tough on our own ignorance. It's the thing that makes
America great. If America weren't incomparably ignorant, how could we
have tolerated the last eight years? -- Frank Zappa, in 1988

Dave Peterson

Open files in the same directory
 
Can you make sure that the workbook is in the same folder as the workbook
running the code:

Set RptWkbk = Workbooks.Open(Filename:=thisworkbook.path & "\" & _
"Individual Report.XLS")

or if you know that file is in the same workbook that is currently active

Set RptWkbk = Workbooks.Open(Filename:=activeworkbook.path & "\" & _
"Individual Report.XLS")



houghi wrote:

At this moment I use something like:

Set RptWkbk = Workbooks.Open(Filename:="Y:\ALL_USERS\Username\St atistics\Department 01\Individual Report.XLS")
I have another file open in the same directory that does the above and
that works wonders.

However I would like it to point to the file with the name "Individual
Report.XLS", but without the drive and such, so I can send it to people
who are on a different machine.

I tried the following, but it did not work:
Set RptWkbk = Workbooks.Open(Filename:="Individual Report.XLS")

Probably prety basic stuff, but I can't seem to figure it out.

houghi
--
Let's not be too tough on our own ignorance. It's the thing that makes
America great. If America weren't incomparably ignorant, how could we
have tolerated the last eight years? -- Frank Zappa, in 1988


--

Dave Peterson

houghi

Open files in the same directory
 
Dave Peterson wrote:
Can you make sure that the workbook is in the same folder as the workbook
running the code:

Set RptWkbk = Workbooks.Open(Filename:=thisworkbook.path & "\" & _
"Individual Report.XLS")


Works great, thanks.

houghi
--
Let's not be too tough on our own ignorance. It's the thing that makes
America great. If America weren't incomparably ignorant, how could we
have tolerated the last eight years? -- Frank Zappa, in 1988


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

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