Open Workbooks present in the same directory

C

cbalajii

Hi,

I am creating a macro that will use data that resides in the same
directory as the file that has the macro code.

My Macro runs like this:

Workbooks.Open "Slash Daily Case Closed.xls"

When I open the file (reports.xls) from explorer and run the macro it
gives me error 1004.

However, when i use File Open and open reports.xls, the macro runs
perfectly fine.

Any help would be greatly appreciated.
 
O

okrob

Hi,

I am creating a macro that will use data that resides in the same
directory as the file that has the macro code.

My Macro runs like this:

Workbooks.Open "Slash Daily Case Closed.xls"

When I open the file (reports.xls) from explorer and run the macro it
gives me error 1004.

However, when i use File Open and open reports.xls, the macro runs
perfectly fine.

Any help would be greatly appreciated.

You need to give the full path... Workbooks.Open "C:\Documents and
Settings\Admin\Desktop\reports.xls" and it'll work both ways...
 
C

cbalajii

I wont be able to give full path because I am creating a report that
multiple people will be running and using this macro... is there an
alternate method ?
 
C

cbalajii

I wont be able to give full path because I am creating a report that
multiple people will be running and using this macro... is there an
alternate method ?

From the following website:
http://www.excel-vba.com/vba-12-code-workbooks.htm
******************start quote************

Opening Workbooks

To open another Excel file (workbook) with a VBA procedure you simply
write (notice that "Workbooks" is plural):
Workbooks.Open "suchAndSuch.xls"
You don't need to specify a directory (path) if the second workbook
resides in the same directory as "ThisWorkbook"

******************end quote************

So, when I open a file from a folder, then I should be able to just
open other files in the same directory ?

Balajii
 

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

Top