I have a report that runs and creates some csv files. I have managed to create a macro and its saved into the personal.xlsb file. What I need to do is somehow run this from a batch file to open the csv, run the macro, and then save the csv and close excel without saving the xlsb.
I tried to run it from a vbs file which can be run from a command line, but it wont run my macro as it says its not available or macros are disabled. I made sure in trust center to enable all macros.
this is the code that is saved in a vbs file.
Option Explicit
LaunchMacro
Sub LaunchMacro()
Dim xl
Dim xlBook
Dim sCurPath
sCurPath = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".")
Set xl = CreateObject("Excel.application")
Set xlBook = xl.Workbooks.Open(sCurPath & "\logins-computer-domain.com.csv", 0, True)
xl.Application.Visible = True
xl.Application.run "C:\Documents and Settings\login\Application Data\Microsoft\Excel\XLSTART\personal.xlsb!Module1.Reports"
xl.DisplayAlerts = False
xlBook.saved = True
xl.activewindow.close
xl.Quit
Set xlBook = Nothing
Set xl = Nothing
End Sub
thanks in advance!
Chris
Bookmarks