locked
Run excel macro in a running excel file RRS feed

  • Question

  • Hello,

    I want to use a Powershell script to run a "update" macro in my already running excel file. I only was able to open a excel file and then run the macro with this code: 

    clear
    $pfad = split-path $script:MyInvocation.MyCommand.Path
    $excel = new-object -comobject excel.application
    $app = $excel.Application
    $app.Run("'C:\Ziel.xlsm'!Import")

    But I want to open the excel file manually and then run my macro every 5 min with the help of the task sheduler.

    Hope someone can help me.

    Greetings

    Torben

    Wednesday, March 28, 2018 7:35 AM

Answers

All replies

  • What you are asking cannot be done.  That is not how the task scheduler.

    Post in Excel forum to learn how to use timers in Excel.  There is no need for PowerShell and Microsoft prohibits running Excel under the task scheduler:

    https://support.microsoft.com/en-us/help/257757/considerations-for-server-side-automation-of-office


    \_(ツ)_/

    Wednesday, March 28, 2018 7:45 AM
  • Okay, is it possible to run a macro from a Powershell in a open excel without the task sheduler?

    I tried to run the excel macro in a loop with a 5 minute pause but the screen stopped updating. So I need a solution to trigger the macro every 5 min without using a loop.

    Wednesday, March 28, 2018 7:56 AM
  • Use a timer event in PowerShell to call the macro.

    Believe me this will be easier if you just change the macro to run every 5 minutes inside of Excel.

    Here are the instructions for using timers in Excel: https://www.datanumen.com/blogs/update-excel-worksheet-periodically-vba-timer/

    Post questions in the Excel VBA forum.  This is not an Excel forum or a VBA forum.


    \_(ツ)_/

    • Marked as answer by Shazyzang Wednesday, March 28, 2018 8:36 AM
    Wednesday, March 28, 2018 8:07 AM