A
alexagran
I've built an Excel add-in that needs to execute some code when the
workbook opens. I've added the following code to the Workbook_Open
event:
Private Sub Workbook_Open()
For Each ws In ActiveWorkbook.Worksheets
If ws.Name = crFinancialsSheet Then
sheetExists = True
End If
Next
End Sub
I add the add-in, close the workbook and open a new instance of Excel.
At this point, the add-in throws an error because the ActiveWorkbook in
the Workbook_Open event is nothing and obviously there are no sheets (I
can visually see that the sheets are not there).
What I'm wondering is why the ActiveWorkbook is nothing in the
Workbook_Open event and is there another event that I can put my code.
I need the workbook to have sheets.
Thanks,
alex
workbook opens. I've added the following code to the Workbook_Open
event:
Private Sub Workbook_Open()
For Each ws In ActiveWorkbook.Worksheets
If ws.Name = crFinancialsSheet Then
sheetExists = True
End If
Next
End Sub
I add the add-in, close the workbook and open a new instance of Excel.
At this point, the add-in throws an error because the ActiveWorkbook in
the Workbook_Open event is nothing and obviously there are no sheets (I
can visually see that the sheets are not there).
What I'm wondering is why the ActiveWorkbook is nothing in the
Workbook_Open event and is there another event that I can put my code.
I need the workbook to have sheets.
Thanks,
alex