BookmarkSubscribeRSS Feed
TiteJoe
Calcite | Level 5

I'm trying to open up SAS Enterprise from VBA to call upon/run a different program. But I'm getting an error "2147213310 (80042002)" which I'm confused about (I've attached the exact error message).

 

This is the first time I've tried to connect from VBA to SAS so everything I have so far has been picked from codes I've found in other forums.

 

    Dim obObjectFactory As New SASObjectManager.ObjectFactory
    Dim obObjectKeeper As New SASObjectManager.ObjectKeeper
    Dim obServer As New SASObjectManager.ServerDef
    Dim obSAS As SAS.Workspace
    Dim cn As New ADODB.Connection
    Dim rs As New ADODB.Recordset
   
    obServer.MachineDNSName = "DummyName"
    obServer.Protocol = ProtocolBridge
    obServer.Port = 8591
    obObjectFactory.LogEnabled = True
   
    Set obSAS = obObjectFactory.CreateObjectByServer("My Server", True, obServer, "MyUserName", "MyPassword")

 

The error is when I run the last line.

 

The SAS Profile I'm trying to connect to has been attached too.

 

I have seen some stuff around about issues running on 32-bit SAS but I have no idea how to get around this?

Has anyone come across this issue before?

 

Thank you,

1 REPLY 1
ChrisHemedinger
Community Manager

The code you shared is for connecting to SAS directly with Integration Technologies. But your screenshots show that you have SAS Enterprise Guide or the SAS Add-In for Microsoft Office.

 

If you have the SAS Add-In for Microsoft Office, start with this paper to learn about VBA and scripting.   Here's a broader, more recent paper from the same expert.

 

If you have SAS Enterprise Guide, then start with this article about EG Automation.

 

If you want to connect to SAS directly and bypass SAS Enterprise Guide and the SAS Add-In for Microsoft Office (though that is more work so I recommend scripting through one of the clients instead), check out this article and code samples on GitHub.

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 1 reply
  • 1252 views
  • 2 likes
  • 2 in conversation