I wrote a code snippet in SAS EG that just opens an Excel workbook. The Excel workbook contains VBA code that executes when the "Workbook Open" event occurs. All code pretty much does this, it updates all data connections the first time it is opened every day.
When I run the SAS program manually, it works exactly as planned. It opens an Excel file, which in turn runs a VBA macro. When I plan to run SAS EG on my server, but the Work is done, but nothing happens with my Excel file. I also do not get any errors in my SAS code or in the Windows Scheduler Log.
Here is my SAS code:
options noxwait noxsync; x '"C:\Program Files\Microsoft Office\Office15\excel.exe" "\\route\to\file\excel_macro_playground.xlsm"'; run;
Here is my VBA:
Private Sub Workbook_Open() Dim wsSheet As Worksheet On Error Resume Next Set wsSheet = Sheets("book_helper") On Error GoTo 0 If wsSheet Is Nothing Then Sheets.Add.Name = "book_helper" ActiveWorkbook.RefreshAll Sheets("book_helper").Range("A1").Value = Date Sheets("book_helper").Visible = xlVeryHidden Application.DisplayAlerts = False ThisWorkbook.Save Application.DisplayAlerts = True Application.Quit Else If Sheets("book_helper").Range("A1").Value < Date Or Sheets("book_helper").Range("A1").Value = "" Then ActiveWorkbook.RefreshAll Sheets("book_helper").Range("A1").Value = Date Sheets("book_helper").Visible = xlVeryHidden 'ActiveWorkbook.Close savechanges:=True 'Application.Quit Application.DisplayAlerts = False ThisWorkbook.Save Application.DisplayAlerts = True Application.Quit End If End If End Sub
And then, of course, I use the SAS EG Scheduling tool to set up the job. All my other jobs are working fine. Is there something I need to change to make it work as expected?
source share