Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
"Tom" wrote in message ...
Is there a command that I can specify at the end of my macro to close the workbook after the macro has ran? I have tried Quit and Close but neither are working. You can use a VB script to run the macro without even opening the workbook. Below is a sample script to run a macro that I found here a while ago: ******** ' Here, the full path name of the workbook to open Const xlName = "Insert the full file name of the workbook here" Dim xl, Wbk Set xl = WScript.CreateObject("Excel.Application") Set Wbk = xl.Workbooks.Open(xlName) ' Here, the workbook macro name to execute (in a standard module) xl.Run "Insert your macro name here" Wbk.Save Wbk.Close False xl.Quit Set xl = Nothing ******** If you copy the above script in a text file, customize the worksheet location and macro name to fit your needs, and save the script with a ".vbs" extension (eg. myscript.vbs), the script will run the macro whether or not the workbook is open or closed. Then, instead of using windows scheduler to open the workbook, simply use the scheduler to open the VB script. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Automate a macros when data in a cell changes (e.g.when using quer | Excel Discussion (Misc queries) | |||
Automate Add-In | Excel Programming | |||
Macro Size Limit / open macros with macros? | Excel Programming | |||
Macros not appearing in the Tools Macro Macros list | Excel Programming | |||
Suppress the Disable Macros / Enable Macros Dialog | Excel Programming |