Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Running a Excel Macro from Windows Scheduler


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/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 391
Default Running a Excel Macro from Windows Scheduler

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/

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Running a Excel Macro from Windows Scheduler


Hi Patrik,
Thanks a lot for your response. I tried your code and it is working.
But I am little confused how to make it work for me. I am giving My
requirement clearly...
I am trying to plot a graph by taking values from a file. For this I
wrote a Macro. Now I want this macro to be run daily at particular
time. Code of the macro is pasted below.


Sub swapmemory()
'
' swapmemory Macro
' Macro recorded 10/20/2003 by ibm user
'
' Keyboard Shortcut: Ctrl+q
'
Dim sDate As String
Dim sfile As String

sDate = Format(Date, "mmddyy")
sfile = "swapmemory_results." & sDate
ChDir "C:\new Applications\Tower-G"
Workbooks.OpenText Filename:= _
"C:\new Applications\Tower-G\results\" & sfile,
Origin:=xlWindows, _
StartRow:=1, DataType:=xlDelimited,
TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False,
Comma:=False _
, Space:=False, Other:=False, FieldInfo:=Array(1, 1)
Range("A1:A340").Select
Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=Sheets(sfile).Range( _
"A1:A340"), PlotBy:=xlColumns
ActiveChart.Location Whe=xlLocationAsObject, Name:= _
sfile
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Swap Memory Results -- GLITR"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = _
"time(each unit = 5min)"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Kb"
End With
End Sub

Could you please tell me how to run this macro daily at particular time
using windows scheduler.


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Running a Excel Macro from Windows Scheduler


Hi Patrick,
I got the solution.
Thanks a lot.


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

Reply
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
Running Excel 2003 on Windows 7 PT[_3_] New Users to Excel 1 December 15th 09 09:02 AM
Running a macro from windows application Aerojade Excel Discussion (Misc queries) 1 October 3rd 08 01:19 PM
Running excel macro by scheduler Dan Excel Discussion (Misc queries) 1 August 19th 07 11:48 PM
Windows Installer keeps running when i open excel laxfan1405 Excel Discussion (Misc queries) 1 July 31st 07 07:44 AM
Excel 2002 / XP - Running .XLS with Macros via Task Scheduler James Cox Excel Programming 0 August 19th 03 03:50 AM


All times are GMT +1. The time now is 07:41 PM.

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

About Us

"It's about Microsoft Excel"