View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Mats Samson Mats Samson is offline
external usenet poster
 
Posts: 112
Default Problem with references/variables

Hello,
Im creating references/variables to other worksheets in other workbooks
but they dont 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 Auto_Open()
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 doesnt
help!!!
I cannot switch back to WTNSystem.xls with this €śabbreviation€ť.

Why?