how can i open a second workbook using a vba code

  • Thread starter Thread starter swain.s
  • Start date Start date
Not if you did not add more to it.

Show us the code you tried that does not work.


Gord Dibben MS Excel MVP
 
this is a code from MACROS MADE EASY

Sub Workbook_Open()
Workbooks.Open("data.xls")
End Sub
 
Include the drive and path, too:

Workbooks.Open("c:\my folder\my other folder\data.xls")

(change as appropriate)
 
What happens when you try it?

Do you have macros enabled?

Are you sure that the data.xls file exists in the drive/folder you specified?

How are you opening the workbook that opens the data.xls workbook?
 
Have you inadvertantly disabled events?

Copy this to Immediate Window

Application.EnableEvents = True and hit Enter


Gord
 
run time error '1004':
yes the macro is enabled when i open the 1st file security warning
yes they are both in the 'C:\ dir
i open test.xls manually and i want it to open data.xls automatically
 
Record a macro when you open that file manually. Use that code in the
workbook_Open event. (I'm guessing that you have a typo in your
drive/path/filename.)

If you have trouble modifying the workbook_open, then post the complete recorded
macro.
 
Back
Top