ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Open Workbook Assignment (https://www.excelbanter.com/excel-programming/403281-open-workbook-assignment.html)

Nigel[_2_]

Open Workbook Assignment
 
Hi All

If I create a new workbook, I can assign it to an object variable...

Dim wB as Workbook
Set wB = Workbooks.Add

How can I open an existing workbook and assign it?

Dim wB as Workbook
Set wB = Workbooks.Open "C:\myWork.xls"

Does not work!

TIA

--

Regards,
Nigel





Bob Phillips

Open Workbook Assignment
 
Dim wB as Workbook
Set wB = Workbooks.Open("C:\myWork.xls")

should work


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Nigel" wrote in message
...
Hi All

If I create a new workbook, I can assign it to an object variable...

Dim wB as Workbook
Set wB = Workbooks.Add

How can I open an existing workbook and assign it?

Dim wB as Workbook
Set wB = Workbooks.Open "C:\myWork.xls"

Does not work!

TIA

--

Regards,
Nigel







Nigel[_2_]

Open Workbook Assignment
 
Many thanks Bob, works a treat.

--

Regards,
Nigel




"Bob Phillips" wrote in message
...
Dim wB as Workbook
Set wB = Workbooks.Open("C:\myWork.xls")

should work


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

"Nigel" wrote in message
...
Hi All

If I create a new workbook, I can assign it to an object variable...

Dim wB as Workbook
Set wB = Workbooks.Add

How can I open an existing workbook and assign it?

Dim wB as Workbook
Set wB = Workbooks.Open "C:\myWork.xls"

Does not work!

TIA

--

Regards,
Nigel









All times are GMT +1. The time now is 06:39 AM.

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