Reputation: 1
I am new to VBA and do not understand enough about Dim to even find the error.
Dim wkbInventory as Workbook
wkbInventory = Application.Workbooks(“myWorkbook.xlsm”)
New to VBA and do not really understand/know enough about Dim to fix this.
Upvotes: 0
Views: 102
Reputation: 11755
First, the “curly quotes”
will not work... you need the "normal ones"
.
Secondly, you need to use Set
- as a Workbook
is an Object
variable.
Dim wkbInventory as Workbook
Set wkbInventory = Application.Workbooks("myWorkbook.xlsm")
That also assumes the workbook is already open, if it is not, then you need to do it like this instead:
Dim wkbInventory as Workbook
Set wkbInventory = Workbooks.Open("C:\Test\myWorkbook.xlsm")
or like this:
Dim wkbInventory as Workbook
Set wkbInventory = Workbooks.Add("C:\Test\myWorkbook.xlsm")
Note: A lot of times, normal quotes will turn into curly quotes if you are copy/pasting from a website that does not format things properly, or you are copy/pasting from something like a Word document. Try to pay attention to that.
Upvotes: 2