WorkbookOpen Event Problems
Upcoming Power Excel Seminars
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 9 of 9

Thread: WorkbookOpen Event Problems

  1. #1
    Board Regular
    Join Date
    Mar 2002
    Posts
    88
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    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. #2
    Board Regular
    Join Date
    Feb 2002
    Location
    Huntington Beach, CA USA
    Posts
    327
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi Keith,

    Try this:

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

    James

  3. #3
    Board Regular
    Join Date
    Mar 2002
    Posts
    88
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    thanks for the help -

    which module should I put this code in to have the code processed right when the workbook is opened?

  4. #4
    Board Regular
    Join Date
    Feb 2002
    Location
    Huntington Beach, CA USA
    Posts
    327
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi again Keith,

    Put it in the "ThisWorkbook"

    Jim

  5. #5
    Legend NateO's Avatar
    Join Date
    Feb 2002
    Location
    Minneapolis, Mn, USA
    Posts
    9,700
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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, NateO

    [ This Message was edited by: NateO on 2002-04-02 19:41 ]

  6. #6
    Legend NateO's Avatar
    Join Date
    Feb 2002
    Location
    Minneapolis, Mn, USA
    Posts
    9,700
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Didn't mean to steal your thunder James, wasn't sure if you were still logged in er not. Have a good eve.

  7. #7
    Board Regular
    Join Date
    Feb 2002
    Location
    Huntington Beach, CA USA
    Posts
    327
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi Nate,

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

    Jim

  8. #8
    Legend NateO's Avatar
    Join Date
    Feb 2002
    Location
    Minneapolis, Mn, USA
    Posts
    9,700
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Agreed. Have a good one.

  9. #9
    Board Regular
    Join Date
    Mar 2002
    Posts
    88
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    Works Great thanks guys!

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 

 
DMCA.com