Use vbs to open an excel workbook, run a macro and save the workbook

前端 未结 1 1536
刺人心
刺人心 2021-01-14 17:44
  • I have a macro that I need to be run every 5 min. I have a vbs file that schedules the macro.
  • The macro is checking for new files in some folder,
1条回答
  •  不知归路
    2021-01-14 18:22

    Updated code below, I have also tweaked the logic of the clean-up

    Dim xlApp, xlBook
    
    Set xlApp = CreateObject("Excel.Application")
    xlApp.DisplayAlerts = False
    Set xlBook = xlApp.Workbooks.Open("W:\Excel Macro\EIM File Maneger\EIM_file_check.xlsm", 0, True)
    
    
    xlApp.Run "GetFiles"
    
    xlbook.Save
    xlBook.Close False
    set xlBook = Nothing
    
    xlApp.Quit
    Set xlApp = Nothing
    
    WScript.Echo "Finished."
    WScript.Quit
    

    0 讨论(0)
提交回复
热议问题