+ Reply to Thread
Results 1 to 5 of 5

Run macro when open workbook

  1. #1
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Bergen, Norway
    MS-Off Ver
    Excel 2010
    Posts
    311

    Run macro when open workbook

    Hi,

    I have arranged that my workbook will oppen at a certain time of of the day by use of task schduler.
    I need some assistance to make a macro run automatic when the workbook opens.

    Today I have the code saved on a comandbutton, but I want to have it located in the workbook.

    Any ideas anyone

    Regards

    Øystein Breivik

  2. #2
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Run macro when open workbook

    I would suggest to move the code you now have linked to the command button to the Workbook_Open event routine in the workbook module. Note that the routine must start with the below specific name:

    Please Login or Register  to view this content.
    If you like my contribution click the star icon!

  3. #3
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Bergen, Norway
    MS-Off Ver
    Excel 2010
    Posts
    311

    Re: Run macro when open workbook

    Sorry for late responce,

    That worked perfect OllieB, but I cant make the workbook open at a certain time by use of task schedule. I have no clue why it wount open when it says that it runs.

    Any ideas anyone?

    Regards
    Øystein Breivik

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,091

    Re: Run macro when open workbook

    Your workbook is macro enabled so it will ask for macros to be enabled when you open it. Presumably, it isn't getting past that point.

    I would suggest you set up a trusted location and open the workbook from there.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  5. #5
    Forum Contributor
    Join Date
    04-02-2012
    Location
    Bergen, Norway
    MS-Off Ver
    Excel 2010
    Posts
    311

    Re: Run macro when open workbook

    Thanks for youre reply,

    What do you mean by "set up a trusted location"? I am only using this workbook on my personal computer, so is there any settings I have to change manually?

    Regards
    Øystein Breivik

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1