SAS Enterprise Guide

Desktop productivity for business analysts and programmers
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
konnos
Calcite | Level 5
Dear All, I am trying to create a macro in EXCEL to run multiple SAS Enterprise Guide .egp programs from Excel. (I am stack 2 days now) I managed to write a code to run one .egp program but if I run the macro again second time before I close the Excel workbook I get a run time error: "Run-time error '-2146233088 (80131500)': Path is not a directory 'C:': The filename, directory name, or volume label syntax is incorrect." This is very strange since I am not working on C: drive. Please see below the excel macro which crashes the second time I run it, at line: Set Proj = ApplicationObj.Open(Path & "SAS1.egp", "") '''''''''''''''''''''''''''' Sub RunFor() Dim ApplicationObj As Object 'Application Dim Proj As Object 'Project object Dim sasProgram As Object 'Code object (SAS program) Dim log1 As String Dim parmList As Variant Dim parm As Variant Dim Path As String Dim Full_Date As Variant Path = "M:\REPORT TO UNIT\KPIs_reports\Run SAS from Excel tests\" Worksheets("KPIs").Activate Full_Date = Cells(9, "C").Value 'On Error GoTo ErrHandler Set ApplicationObj = CreateObject("SASEGObjectModel.Application.7.1") Set Proj = ApplicationObj.Open(Path & "SAS1.egp", "") 'Set Proj = ApplicationObj.Open(Path & "SAS1.egp", "") Set parmList = Proj.Parameters MsgBox "Project has " & parmList.Count & " parameters." Set parm = parmList.Item(0) 'MsgBox parm.Name & " parameter has default value of " & parm.DefaultValue MsgBox parm.Name & " parameter" parm.Value = Full_Date MsgBox parm.Name & " parameter has been set to value of " & parm.Value Proj.Run 'Set Proj = Nothing 'Set ApplicationObj = Nothing Proj.SaveAs "M:\REPORT TO UNIT\KPIs_reports\Run SAS from Excel tests\SAS1.egp" Proj.Close ApplicationObj.Quit ''''''''&Preivous_Date ,is the prompt in SAS ActiveWorkbook.RefreshAll End End Sub '''''''''''''''''''''''''''''''''''''''''' Please let me know your thoughts. Thanks in advance.
1 ACCEPTED SOLUTION
10 REPLIES 10
konnos
Calcite | Level 5
How can I post it with Format. it always makes the text continues
konnos
Calcite | Level 5
Thank you for your reply. I am new in this, can you please explain what is the {i} button please.
Kurt_Bremser
Super User

@konnos wrote:
Thank you for your reply. I am new in this, can you please explain what is the {i} button please.

You see it on top of the main posting window, it's the 6th icon; "little running man" is the 7th.

konnos
Calcite | Level 5
Sorry Kurt, I can not find any icons on top of the Posting window. I have attached a .txt file with my question. (I clicked reply, and it only allows me to write something in the box. Either "Rich Text", "HTML", and "Preview". No other options. Thanks
Kurt_Bremser
Super User

My other argument is still valid. Different behaviour on subsequent runs points to some uninitialized resource, where the 'null' or random value encountered in the first run is replaced with some (default?) value and causes the second and following runs to fail.

That is an observation from 4 decades of programming, not specific to VBA. I don't even touch that with a ten-yard pole, but you should review your code along this aspect. It might be that some module you use is not safe for reuse in the same context, and mandates a restart of Excel.

konnos
Calcite | Level 5
Hi Kurt, Thank you for your comment. I followed your suggestion and have tried to figure out which variable is the one causing this issue and I tried to initialize, clear, all variables before and after finishing the macro, but the issue still persists. I starting to believe that this is a bug of CreateObject("SASEGObjectModel.Application.7.1") Thanks,

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 10 replies
  • 5645 views
  • 1 like
  • 2 in conversation