ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Code for Opening a Closed Workbook (https://www.excelbanter.com/excel-programming/282182-code-opening-closed-workbook.html)

scrabtree23[_2_]

Code for Opening a Closed Workbook
 
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.



Tom Ogilvy

Code for Opening a Closed Workbook
 
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.

--
Regards,
Tom Ogilvy

scrabtree23 wrote in message
...
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.





Seth[_6_]

Code for Opening a Closed Workbook
 
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

-----Original Message-----
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.


.


Tom Ogilvy

Code for Opening a Closed Workbook
 
No, that won't work.

See my post for the correct syntax.

--
regards,
Tom Ogilvy

Seth wrote in message
...
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

-----Original Message-----
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.


.





All times are GMT +1. The time now is 06:59 PM.

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