0

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)

LioudQQ
  • 3
  • 3
  • What is the purpose of the macro you want to run? – Daniel Mann Nov 27 '16 at 23:12
  • The main macro takes the test log and calculate some numbers, then save if as an Excel Workbook. I need to do it with Excel so other options aren't good – LioudQQ Nov 28 '16 at 07:37
  • Did you try to use your build service account to run this command line on the remote build agent? And how about put this Excel Macro in a batch script http://stackoverflow.com/questions/2050505/way-to-run-excel-macros-from-command-line-or-batch-file and executing a batch file through InvokeProcess Activity? – PatrickLu-MSFT Nov 28 '16 at 10:04
  • Batch file also don't work. Just nothing happens :/ And I can't try it with build service account but I think this account must have enough permision to do it – LioudQQ Nov 28 '16 at 11:51
  • Can you share the build definition you customized? – Eddie Chen - MSFT Nov 30 '16 at 05:51
  • The build Definition is mostly the same. I didn't delete anything from the Standard template only added some Arguments for the process, which is working fine. Only the Excel macro doesn't work. – LioudQQ Dec 05 '16 at 13:28
  • @LioudQQ Which build definition template do you use and what's your TFS server version? You mentioned "InvokeProcess" Activity but it does not exist in the default build template. – Eddie Chen - MSFT Dec 06 '16 at 02:19
  • I'm using Version 2012. And sorry but I can't tell you which template it is, I didn't downloaded it :/ The InvokeProcess Activity was added by myself – LioudQQ Dec 06 '16 at 12:01

0 Answers0