M
Mats Samson
Hello,
I’m creating references/variables to other worksheets in other workbooks
but they don’t work when returning to the original workbook sheet.
“Run time error 91: Object variable or With block variable not setâ€
The two workbooks are loaded at one time and in the first/â€mainâ€
(WTNSystem.xls)
there is a module containing:
Public WSS As Worksheet, WSC As Worksheet, WSD As Worksheet, WSO As Worksheet
Public Sub Autpen()
ChDir ("D:\My Documents\Excel\Calc")
Workbooks.Open Filename:="WTNDatabase.xls"
Set WSS = Workbooks("WTNSystem").Worksheets("System")
Set WSC = Workbooks("WTNSystem").Worksheets("Calculation")
Set WSD = Workbooks("WTNDatabase").Worksheets("Database")
Set WSO = Workbooks("WTNDatabase").Worksheets("Offers")
WSS.Activate
End Sub
The second workbook is opened and everything works fine as long as I stay
within the “main†workbook and I can switch to the WTNDatabase.xls workbook
but returning to WTNsystem.xls with the code: WSC.Activate triggers the error.
I even put the same code as above in the WTNDatabase.xls , but it doesn’t
help!!!
I cannot switch back to WTNSystem.xls with this “abbreviationâ€.
Why?
I’m creating references/variables to other worksheets in other workbooks
but they don’t work when returning to the original workbook sheet.
“Run time error 91: Object variable or With block variable not setâ€
The two workbooks are loaded at one time and in the first/â€mainâ€
(WTNSystem.xls)
there is a module containing:
Public WSS As Worksheet, WSC As Worksheet, WSD As Worksheet, WSO As Worksheet
Public Sub Autpen()
ChDir ("D:\My Documents\Excel\Calc")
Workbooks.Open Filename:="WTNDatabase.xls"
Set WSS = Workbooks("WTNSystem").Worksheets("System")
Set WSC = Workbooks("WTNSystem").Worksheets("Calculation")
Set WSD = Workbooks("WTNDatabase").Worksheets("Database")
Set WSO = Workbooks("WTNDatabase").Worksheets("Offers")
WSS.Activate
End Sub
The second workbook is opened and everything works fine as long as I stay
within the “main†workbook and I can switch to the WTNDatabase.xls workbook
but returning to WTNsystem.xls with the code: WSC.Activate triggers the error.
I even put the same code as above in the WTNDatabase.xls , but it doesn’t
help!!!
I cannot switch back to WTNSystem.xls with this “abbreviationâ€.
Why?