Code for Opening a Closed Workbook

S

scrabtree23

I am trying to open a closed workbook using VBA code. I
used this code:

Workbooks("Functions.xls").Open

In the "ThisWorkbook" Object using a Workbook_Open () and
got a "Subscript out of range" error.
 
T

Tom Ogilvy

Workbooks.Open Filename:="C:\My Files\Function.xls"

a workbook isn't in the workbooks collection (which is what you show) until
it is opened and is currently open.
 
S

Seth

You are getting the error because you are not specifying
the file path. This will work:

Workbooks("C:\My Documents\Functions.xls").Open

Of course, I have no idea where the "Functions.xls" has
been saved - replace with the proper directory.

Seth
 

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