+ Reply to Thread
Results 1 to 6 of 6

How do I automatically open a workbook at a set time?

  1. #1
    Registered User
    Join Date
    08-30-2012
    Location
    Glasgow
    MS-Off Ver
    Excel 2003
    Posts
    3

    How do I automatically open a workbook at a set time?

    Hi,

    I'm pretty new to Macro's in excel and after searching the forum i'm still unsure how to acheive this.

    I'm looking for a Macro that will open an excel file at a particular time then another that will save and close the same workbook 5 minutes later. I only say another as i'm not sure if this coudl be aceived using one Macro.

    Any help would be great.

    thanks,
    Last edited by Richard Buttrey; 08-30-2012 at 06:42 AM. Reason: Inadequate title

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Excel 2003 Macro's

    Hi, and welcome to the forum. Unfortunately your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.
    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.



    Since you are new here I'll change the title for you on this occasion, but please note for the future.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    08-30-2012
    Location
    Glasgow
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: How do I automatically open a workbook at a set time?

    Ok thanks, i'll remeber that in the future.

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: How do I automatically open a workbook at a set time?

    Hi,

    Is the workbook that you want to use to drive the macros itself going to be open? You can only get a macro to kick in if the workbook that contains it is open in memory.

    Otherwise you'll need to schedule a task in Windows to open the Excel file which could then auto run the macros you want.

    The following two macros will kick off the workbook open process

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Then in the workbook that is opened and which has to be closed include the following two macros

    Please Login or Register  to view this content.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    08-30-2012
    Location
    Glasgow
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: How do I automatically open a workbook at a set time?

    Thanks Richard, I appreciate your help on this.

    Yesterday afternoon I found out about windows task scheduler and had used this to open the workbook, however the Macro I then used never ran. In addition to closing the workbook I also have a copy and paste.

    I normally use ALT+F11 once the workbook is open to enter visual basic mode. Where do I put the first macros used to open the workbook? or should i still need this when using the task scheduler?


    I have the following code within the workbook.

    Private Sub Workbook_Open()
    Application.OnTime TimeValue("14:05:00"), "CopyValues"
    End Sub

    And the following code on a module

    Please Login or Register  to view this content.
    Last edited by Richard Buttrey; 08-31-2012 at 06:16 AM. Reason: Missing Code tags

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: How do I automatically open a workbook at a set time?

    Hi,

    You're committing a cardinal sin by not putting your code in code tags. I'll change it for you but please remember for next time.

    Please Login or Register  to view this content.
    Then two module level procedures. Note that your original code can be much simplified. You rarely need to use .Select and .Activate. I've left it in place for note but it doesn't run because of the End instruction. Just remove your code.
    In addition it's usually good practice to refer to objects with their complete name. As a minimum use the Sheetname.Range construction, and if several workbooks are involved the WorkbookName.SheetName.Range. That way the code will run correctly whichever sheet happens to be the active sheet. The problem with not specifying a sheet name is that the code will run but always on the currently active sheet which may have detrimental effects.

    Lastly avoid using sheet tab names like "Formulas". Users often change these and in which case your macro will fall over. Always use the sheet Code name.



    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

+ 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