Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Las Vegas, Nevada, USA
    Posts
    334
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Auto-execute VBA code on workbook open

    I found this sample code but it doesn't want to run when I open the file I added it to. I tried to exit Excel and then reopen the file, but still no luck.

    Private Sub Workbook_Open()
    MsgBox "Workbook_Open", vbInformation, "more text"
    End Sub

    What should I look for in troubleshooting this problem?

  2. #2
    3 Star Lounger
    Join Date
    Apr 2002
    Location
    Redditch, Worcestershire, England
    Posts
    233
    Thanks
    0
    Thanked 22 Times in 21 Posts
    Quote Originally Posted by Arcturus16a View Post
    I found this sample code but it doesn't want to run when I open the file I added it to. I tried to exit Excel and then reopen the file, but still no luck.

    Private Sub Workbook_Open()
    MsgBox "Workbook_Open", vbInformation, "more text"
    End Sub

    What should I look for in troubleshooting this problem?
    If you put other macros in the same file, do they run? Do have macro security set to High or to Disable without warning? Do you get any messages at all from Excel?

  3. #3
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts
    Is the code located in the ThisWorkbook Object? It needs to be located there.

    Steve

  4. #4
    New Lounger
    Join Date
    Jun 2014
    Posts
    20
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Make sure you saved it a macro enabled.

Posting Permissions

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