Consulting

Results 1 to 10 of 10

Thread: Solved: Macro to AutoRun at Night on Network - will it work?

  1. #1

    Solved: Macro to AutoRun at Night on Network - will it work?

    I have a macro that refreshes 12 pivot tables during the night. I have it set to 4AM EDT right now. My questions are:

    1.) If I have it stored on a network drive, what will happen? Will it run?
    2.) If I don't specify a time for it to end, will it run everynight?
    3.) Do I have to run it from a specific machine?
    4.) Do I have to have the file which contains the code open?

    Any help would be appreciated.
    Thanks,
    SherryO

    [VBA]
    Application.OnTime EarliestTime:=TimeValue("17:00:00")

    Workbooks.Open Filename:="C:\_sjr\ProjectAnalysis\ProRepPTs.xls"
    Workbooks("proreppts.xls").Activate
    Sheets("Stat").Select
    Selection.QueryTable.Refresh BackgroundQuery:=False
    Sheets("ActCost").Select
    ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
    Workbooks("ProRepPTs.xls").Close xlSaveChanges = 1
    [/VBA]

    Edited 10-Apr-07 by geekgirlau. Reason: insert vba tags

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    If I was to to this, I'd probably use Windows Scheduled Tasks to open an Excel file with a Workbook open event to run the code.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    What is Windows Scheduled Tasks? I've never heard of it. Thanks

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Click the start button, click on Help, and lookup 'Schedule a new task'.

  5. #5
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Start/All Programs/Accessories/SystemTools/Scheduled Tasks
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  6. #6
    Very cool. Does this have to run from one given machine? I work remotely, so I would have to find a machine to run it. thank you so much.

  7. #7
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    I think this will have to be run from 1 machine. I've never got involved in remote working, so don't know of other possibilities.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  8. #8
    VBAX Master
    Joined
    Jul 2006
    Location
    Belgium
    Posts
    1,286
    Location
    When using terminal server sessions ... you can log in via the remote machine and in this session, make a task with the taskscheduler. Disadvantage is that you may not log off of your session but click the x in the middle of your screen. Your session will rest active on the server and the task will be performed. This will only work if the session period can be unlimited. If company polices are that a session can be active for about 4 hours (or less) max and than shuts down automatically, this won't help you alot.

    I, for example must remember that I logged in from my homecomputer or I can't log in via the head server before I close down my remote session. In other words, I have to terminate the remote session before I attempt to login at the normal way (sitting at my desk at work).

    Charlize

  9. #9
    Moderator VBAX Guru Ken Puls's Avatar
    Joined
    Aug 2004
    Location
    Nanaimo, BC, Canada
    Posts
    4,001
    Location
    I'm curious as to your setup. Any way you slice this, it will need to be run on A machine. The versatility depends on how you set it up.

    If you do use Windows scheduled tasks, you're stuck to the machine you set up the task on. If you use the OnTime method in the workbook, you can use it on any machine, but you'll have to leave the Excel session open overnight.

    Either way, you need a PC left on overnight to run the task.

    Charlize's question is interesting though... if I needed to do this, I would set up the task on the server console of my terminal server. It's always logged in, so would always run overnight without me having to leave another machine going.
    Ken Puls, CMA - Microsoft MVP (Excel)
    I hate it when my computer does what I tell it to, and not what I want it to.

    Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar

    This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!

    Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!





  10. #10
    Thank you for the advise. I'll talk to my network guys and see if I can work it out. SherryO

Posting Permissions

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