Example.
Open a new workbook , add this code to a standard module:
''''''''''''''''''''''''''''''''''''''
Sub Initialise(text As String)
MsgBox text
End Sub
''''''''''''''''''''''''''''''''''''''''
save the file as C:\MyFolder\Dummy.xls
and close it.
Open Notepad and add this:
''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
Dim XLApp
Dim wbMain
Dim FSO
Dim sExcelPath
sExcelPath = "C:\myfolder\dummy.xls"
Main
SUB Main()
Set FSO = CreateObject("Scripting.FileSystemObject")
' first check the XL file exists
If Not FSO.FileExists(sExcelPath) Then
msgbox "Unable to Find Excel File: " &
sExcelPath
else
Set XLapp = CreateObject("Excel.Application")
Set wbMain = XLApp.Workbooks.Open(sExcelPath)
with XLApp
.Run "Initialise", "Hello World"
.DisplayAlerts = False
wbMain.Close False
.DisplayAlerts = True
Set wbMain = Nothing
End With
XLApp.Quit
Set XLApp = Nothing
End If
End Sub
''''''''''''''''''''''''''''''''''
save as selecting all file types in a well know
location...with any name with the extension .VBS eg
MyDemo.VBS
close notepad
locate the vbs ( VBSript) fiel that you just created and
double click.
Whe script uses the File System Object to confirm that
the xl workbook exists, then it instantiates excel, opens
the workbook, call the procedure, passing it the text
message, then closes the workbook without saving it and
quits excel.
Excel will open invisibly- so if you have Task Manager
open to Processes you'll see it appear the diasppear.
You now need to open Windows Scheduler and set it to
start the VBS at whatever time that you want.
Patrick Molloy
Microsoft Excel MVP
-----Original Message-----
Hi,
I want to run a Microsoft Excel Macro using Windows
Scheduler . Could
anybody help me in this?
Thanks in advance.
------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from
http://www.ExcelForum.com/
.