Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 8 of 8

Thread: Run Macro on Open?

  1. #1
    New Member
    Join Date
    Apr 2002
    Location
    USA
    Posts
    17
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I don't know much about Visual Basic...but is there a way to make one of my Macros run when the file is opened?

  2. #2
    Board Regular
    Join Date
    Feb 2002
    Posts
    3,184
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    sure

    add the code required into the Auto_Open() sub routeen...


    Free Excel based Web Toolbar available here.

    Jack in the UK
    J & R Excel Solutions
    "making Excel work for you"

  3. #3
    New Member
    Join Date
    Apr 2002
    Location
    USA
    Posts
    17
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Thanks Jack. Is that the code required?

  4. #4
    Board Regular
    Join Date
    Feb 2002
    Posts
    3,184
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    not really

    try

    Sub Auto_Open()

    you code

    End Sub

    need to assign this to mudule, open excle click yes to macro warning and you code will run

    HTH






    Free Excel based Web Toolbar available here.

    Jack in the UK
    J & R Excel Solutions
    "making Excel work for you"

  5. #5
    MrExcel MVP lenze's Avatar
    Join Date
    Feb 2002
    Location
    Helena, MT
    Posts
    13,690
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    You can also place the code in the ThisWorkbook module. Right click on the Excel icon to the left of the file name in the title bar and choose view code. Change general to WorkBook. The open event is the default routine

  6. #6
    Board Regular
    Join Date
    Feb 2002
    Posts
    3,184
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi Lenze

    i use Auto_Open(0

    much any diffeernce???

    just intrested old habbit i guess..



    Free Excel based Web Toolbar available here.

    Jack in the UK
    J & R Excel Solutions
    "making Excel work for you"

  7. #7
    New Member
    Join Date
    Apr 2002
    Location
    USA
    Posts
    17
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Thanks to both of you!

    It's working now.

    Thanks again.

  8. #8
    MrExcel MVP Ivan F Moala's Avatar
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    4,209
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-04-24 14:57, Jack in the UK wrote:
    Hi Lenze

    i use Auto_Open(0

    much any diffeernce???

    just intrested old habbit i guess..



    A workbook opened via code with the Auto_Open
    code in it will NOT run the Auto open code
    unless explicitly called.

    Private Sub Workbook_Open()
    AFIK you cannot disable via code from another workbook (except through Enableevents)ie.
    Opening a workbook via code with Auto open
    you can disable the running of the Auto open.
    Openning a workbook via code that has
    Private Sub Workbook_Open() you cannot
    (Except through Disable events)

    The Diff are subtle but you can use this
    to your advantage.


    Kind Regards,
    Ivan F Moala From the City of Sails

Some videos you may like

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
  •