At the end of my TFS Build process I want to start an excel macro through the "InvokeProcess" Activity. Therefore I have written a seconds macro which starts Excel and execute the macro.
Option Explicit
On Error Resume Next
CallMacro
sub CallMacro()
Dim xlApp
Dim xlBook
Set xlApp = CreateObject("Excel.Application")
xlApp.DisplayAlerts = False
Set xlBook = xlApp.Workbooks.Open("C:\Users\Username\Directory\File.xlsm", 0, True)
xlApp.Run "Macro"
xlApp.Quit
Set xlBook = Nothing
Set xlApp = Nothing
End Sub
My Problem is when ever my Build Process start this Macro nothing will happen. I don't get any errors, warnings or results. If I try manually to execute this macro through command line everything is fine. Is there a mistake in my macro or is it a problem with TFS, and how can i solve this?
EDIT: Tried now with an easier script but same result, just nothing happens.
Dim test, file
Set test = CreateObject("Scripting.FileSystemObject")
Set file = test.CreateTextFile("C:\Users\Username\Desktop\filename.txt")
file.Write "First Row" & vbCrLf & "Second Row" & vbCrLf & "End"
file.Close
Thanks in Advance
EDIT: Could it be that the TFS-Account just can't start the Excel.exe? Because the second script (which just writes in a file) works fine now, but when ever I add to start Excel just nothing happens and my build process run forever. (on the build Server there is no Excel.exe in Task Manager the whole time)