Checking a workbook when it is opened

R

RobH

I want Excel to check the data on every workbook that gets opened. If
certain criteria are met, then some processing will be carried out.

I have set up the event Workbook_Open to run, and this gets triggered
ok. I have a problem with this though. When I open an existing
workbook with Excel not previously running, the open routine gets
triggered twice. I guess that this is once for the PERSONAL.XLS
workbook and then again for the actual workbook. This is a problem,
as when it gets triggered the first time, the PERSONAL.XLS sheet is
hidden so if I try to look at anything on the sheet, the code falls
over.

Any assistance would be appreciate...

Rob
 
N

NickHK

Rob,
Assuming something similar to Chip's method:
http://www.cpearson.com/excel/AppEvent.htm

check if the window is visible first:

Private Sub App_WorkbookOpen(ByVal Wb As Excel.Workbook)

If Wb.Windows(1).Visible = True Then
MsgBox "Application Event: WorkbookOpen: " & Wb.Name
Else
'Do nothing ?
End If

End Sub

NickHK
 
R

RobH

Rob,
Assuming something similar to Chip's method:http://www.cpearson.com/excel/AppEvent.htm

check if the window is visible first:

Private Sub App_WorkbookOpen(ByVal Wb As Excel.Workbook)

If Wb.Windows(1).Visible = True Then
MsgBox "Application Event: WorkbookOpen: " & Wb.Name
Else
'Do nothing ?
End If

End Sub

NickHK









- Show quoted text -

Thanks NickHK, that worked a treat.

Rob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top