Reputation: 10305
I have a vbscript that runs an excel macro. Everything seems right, but it is not working as I had hoped. The task starts but then just continuously running without doing anything.
Let me show you everything I have... I don't get any errors, it just isn't running properly.
Task scheduler Timeline
After that it just says "running" and doesn't execute anything.
My VBScript: (runTest.vbs)
Dim xlApp
Dim xlBook
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open("\\fileserver\homeshares\Tsee\My Documents\Programming\Task Scheduler\runTask.xlsm", 0, True)
xlApp.Run "runTaskTest"
xlBook.Close
xlApp.Quit
Set xlBook = Nothing
Set xlApp = Nothing
My excel Sheet and Macro: (runTask.xlsm)
Sub runTaskTest()
Dim erow As Long
erow = Cells(Rows.Count, "A").End(xlUp).Row
Cells(erow + 1, 1).FormulaR1C1 = "This test was successful : " & Now
ThisWorkbook.Save
End Sub
Any help would be much appreciated. Thanks in advance!
Path network:
Upvotes: 2
Views: 7065
Reputation:
Further to the comments
modify your VBS file
Dim xlApp
Dim xlBook
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open("\\fileserver\homeshares\Tsee\My Documents\Programming\Task Scheduler\runTask.xlsm", 0, False)
xlApp.DisplayAlerts = False
xlApp.Visible = False
xlApp.Run "runTaskTest"
xlBook.Saved = True
xlBook.Save
xlBook.Close
xlApp.Quit
Set xlBook = Nothing
Set xlApp = Nothing
and your macro
Sub runTaskTest()
Dim erow As Long
erow = Sheets(1).Cells(Rows.Count, "A").End(xlUp).Row
Sheets(1).Cells(erow + 1, 1).Value = "This test was successful : " & Now
ThisWorkbook.Saved = True
ThisWorkbook.Save
End Sub
and it should work
Upvotes: 1