Dear Vbaers,
I've managed to run this macro in excel itself with no problems. As I'm not familiar with running vbs script from task scheduler, i'm kinda stuck with no clue. Any help?
Here's my excel code which is running fine.
[vba]
Sub send_range()
Application.Calculate
Application.DisplayAlerts = False
Dim ws1 As Worksheet
Set ws1 = Worksheets("Tracker")
With ws1
.ListObjects(1).Unlist
.Range("A:ZZ").EntireColumn.Hidden = False ' show all hidden column
.AutoFilterMode = False
.Range("A10:J10").AutoFilter
.Range("A10:J10").AutoFilter Field:=8, Criteria1:="<=" & Now(), _
Operator:=xlOr, Criteria2:="<=" & Now() + 30
End With
ActiveSheet.Range("10:" & Range("j100").End(xlUp).Row).Select
ActiveWorkbook.EnvelopeVisible = True
With ActiveSheet.MailEnvelope
.Introduction = "This is an automated generated file. Please update the file: [Expiry Date Tracker.xlsm] in the system."
.Item.to = aloy78@yahoo.com
.Item.Subject = "REF: Expiry List"
.Item.send
End With
ActiveWorkbook.Close False
End Sub
[/vba]
I search google on how to do a vbs script, and my only clue is this:
[vba]
Dim args, objExcel
Set args = WScipt.Arguments
Set objExcel = CreateObject("Excel.Application")
objExcel.Workbooks.Open args(0)
objExcel.Visible = True
objExcel.Run "send_range", args(1)
objExcel.ActiveWorkbook.Save
objExcel.ActiveWorkbook.Close(0)
objExcel.Quit
[/vba]
Any idea where did I go wrong in the vbs script? I believe it is the vbs script that is not working cos I have problem running my excel code.
Many thanks ahead.