Roger has attended:
Excel VBA Intro Intermediate course
Excel VBA Advanced course
Assigning a variable to a workbook using "Set"
Can someone tell me what is wrong with the second statement below, please? The first one works OK and I am certain that the path is correct in the second.
Thanks
Roger
Set wb = Workbooks("SetVar.xlsm")
Set wb = Workbooks("C:\msoffice\excel\SetVar.xlsm")
RE: Assigning a variable to a workbook using "Set"
Hi Roger.
The Workbooks collection refers to the open workbooks so it doesn't include an option for the file path.
Could the path "C:\moffice\excel\" be added later as a variable? For example for saving the file:
Dim fp as String
fp = "C:\moffice\exel\"
Set wb = Workbooks("SetVar.xlsm")
wb.SaveAs Filename:=fp & "Setvar.xlsm", FileFormat:= _
xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
Regards
Doug
Best STL