LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Automate Macros

"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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automate a macros when data in a cell changes (e.g.when using quer jwwjd Excel Discussion (Misc queries) 5 June 24th 05 03:06 PM
Automate Add-In Geerty Excel Programming 2 June 6th 04 11:27 PM
Macro Size Limit / open macros with macros? andycharger[_7_] Excel Programming 6 February 13th 04 02:00 PM
Macros not appearing in the Tools Macro Macros list hglamy[_2_] Excel Programming 5 October 24th 03 09:10 AM
Suppress the Disable Macros / Enable Macros Dialog Shoji Karai Excel Programming 5 September 24th 03 03:10 AM


All times are GMT +1. The time now is 02:35 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"