Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Aug 2006
    Location
    Gtr London, England
    Posts
    256
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Run macro on opening (VBA Excel 2003)

    Hi,

    Im having trouble with getting the right syntax for running a macro on opening book1.xls workbook.

    I know in Word its Sub Auto_Open().

    For Excel Ive tried Public Sub Workbook_Activate(), and ThisWorkbook.Activate. For testing purposes Im just trying to display the usual 'Hello World' message, but nothing happens on opening Excel.

    Can anyone point me in the right direction please??

    Many Thanks.
    Lee

  2. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts

    Re: Run macro on opening (VBA Excel 2003)

    Hi Lee,

    For Excel, the 'auto' macros are:
    Auto_Open, Auto_Close, Auto_Activate, and Auto_Deactivate
    These are only included for backward compatibility, so you should use the Workbook Open, Close, Activate and Deactivate events instead (eg Private Sub Workbook_Open()).
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  3. #3
    3 Star Lounger
    Join Date
    Aug 2006
    Location
    Gtr London, England
    Posts
    256
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Re: Run macro on opening (VBA Excel 2003)

    Hi Paul,

    Many thanks for that, it works perfectly.

    Cheers.
    Lee

Posting Permissions

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