PDA

View Full Version : SAS add in Advanced VBA question



jmutsche
01-14-2014, 11:50 AM
Hello,

I am trying to figure out how to call a stored process flow from SAS usingvba. I found some information Online... here is my code.

Sub InsertSasDataSet()
Dim sas As SASExcelAddIn
Set sas = Application.COMAddIns.Item("SAS.ExcelAddIn").Object
sas.InsertStoredProcess "P:\HumanDev\QA\Staff\REPORT SPECIALIST\James Mutscheller\My Reports\Weekly\HD\Conversions.egp", Sheet1.Range("A1")

End Sub


I get the error Run time error '-2146233086 (80131502)':
Length cannot be less than zero
Parameter name: length

any help would be greatly appreciated.

Kenneth Hobs
01-14-2014, 12:02 PM
Did you set the object in Tools > References?

Step through the code by F8 to see which line of code it errors on.

jmutsche
01-16-2014, 08:07 AM
Yes I did. Error on line 3

Kenneth Hobs
01-16-2014, 09:48 AM
You should have seen that error before running when you compile the program. If you are not using the Debug menu's Compile before running code, I recommend doing that. As I explained, that would indicate that you have not set the SAS reference.

This explains what I am talking about. http://scienceofanalytics.com/2013/08/04/sas-auto-part-1/

jmutsche
01-18-2014, 11:15 AM
I'v read that and I had already done as i said before. I know Google is a great tool but this is pretty specialized stuff. I have the 4.3 add I'm and i checked the box for it. It's not a terrible thing if i can't make it work, but if I can it will take my programming to the next level.

Bob Phillips
01-19-2014, 11:09 AM
Did you Trust access to the VBA project object model?

snb
01-19-2014, 01:25 PM
did you check


sub tst()
msgbox dir("P:\HumanDev\QA\Staff\REPORT SPECIALIST\James Mutscheller\My Reports\Weekly\HD\Conversions.egp"
End Sub


and

sub tst()
getobject("P:\HumanDev\QA\Staff\REPORT SPECIALIST\James Mutscheller\My Reports\Weekly\HD\Conversions.egp").application.visible=true
End Sub