WorkbookOpen Event Problems

keith

Board Regular
Joined
Mar 3, 2002
Messages
88
I am trying to launch a userform when the workbook is opened. Following the VBA help files, I created a new class module with the "Public WithEvents App As Application" declaration. Then here is my code:

Private Sub App_WorkbookOpen(ByVal Wb As Workbook)
If Worksheets(Main).Range(C5).Value = 0 Then UserForm1.Show
End Sub

I may be way off base and not doing it right at all.. thanks in advance
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Hi Keith,

Try this:

Private Sub Workbook_Open()
If Worksheets("Sheet1").Range("C5").Value _
= 0 Then
Userform1.Show
End If
End Sub

James
 
Upvote 0
thanks for the help -

which module should I put this code in to have the code processed right when the workbook is opened?
 
Upvote 0
In the "ThisWorkbook" module:

Code:
Private Sub Workbook_Open() 
If Worksheets("Sheet1").Range("C5").Value _ 
= 0 Then 
Userform1.Show 
End If 
End Sub
In a normal module:

Code:
Private Sub auto_Open() 
If Worksheets("Sheet1").Range("C5").Value _ 
= 0 Then 
Userform1.Show 
End If 
End Sub

Hope this helps.

_________________
Cheers,<font size=+2><font color="red"> Nate<font color="blue">O</font></font></font>
This message was edited by NateO on 2002-04-02 19:41
 
Upvote 0
Didn't mean to steal your thunder James, wasn't sure if you were still logged in er not. Have a good eve.
 
Upvote 0
Hi Nate,

No problem, just glad to be able to help
after all that's what it's all about.

Jim
 
Upvote 0

Forum statistics

Threads
1,213,551
Messages
6,114,266
Members
448,558
Latest member
aivin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top