![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Mar 2002
Posts: 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 |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Feb 2002
Location: Huntington Beach, CA USA
Posts: 327
|
Hi Keith,
Try this: Private Sub Workbook_Open() If Worksheets("Sheet1").Range("C5").Value _ = 0 Then Userform1.Show End If End Sub James |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Mar 2002
Posts: 88
|
thanks for the help -
which module should I put this code in to have the code processed right when the workbook is opened? |
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Feb 2002
Location: Huntington Beach, CA USA
Posts: 327
|
Hi again Keith,
Put it in the "ThisWorkbook" Jim |
|
|
|
|
|
#5 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
In the "ThisWorkbook" module:
Code:
Private Sub Workbook_Open()
If Worksheets("Sheet1").Range("C5").Value _
= 0 Then
Userform1.Show
End If
End Sub
Code:
Private Sub auto_Open()
If Worksheets("Sheet1").Range("C5").Value _
= 0 Then
Userform1.Show
End If
End Sub
_________________ Cheers, NateO [ This Message was edited by: NateO on 2002-04-02 19:41 ] |
|
|
|
|
|
#6 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
Didn't mean to steal your thunder James, wasn't sure if you were still logged in er not. Have a good eve.
|
|
|
|
|
|
#7 |
|
Board Regular
Join Date: Feb 2002
Location: Huntington Beach, CA USA
Posts: 327
|
Hi Nate,
No problem, just glad to be able to help after all that's what it's all about. Jim |
|
|
|
|
|
#8 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
Agreed. Have a good one.
|
|
|
|
|
|
#9 |
|
Board Regular
Join Date: Mar 2002
Posts: 88
|
Works Great thanks guys!
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|