Showing results for 
Search instead for 
Did you mean: 
Showing results for 
Search instead for 
Did you mean: 

VB API not able to connect -- some error-- help


VB API not able to connect -- some error-- help



i have all set up VB api in my pc along with i have marked vb reference in creo as well but when i try to run below code i am getting error;


'globale Variablen:
Dim asyncConnection As IpfcAsyncConnection
Dim cAC As CCpfcAsyncConnection
Dim hSession As IpfcBaseSession
Dim hCurMdl As IpfcModel

Function Connect2ProE() As Boolean

Set cAC = New CCpfcAsyncConnection
Set asyncConnection = cAC.Connect(Null, Null, Null, Null)
Set hSession = asyncConnection.session

Connect2ProE = True

End Function

Private Sub but_connect_proe_Click()

bProeConnect = Connect2ProE()

End Sub




your help really be appreciated. Thanks



@remy input on this please

21-Topaz I

Hi @Ragnarok8979 

You need assistance with your VB code throwing an error. Let's clarify a little my scope: I cover several Creo Toolkit offerings and VB is not part of that. i'm sorry.
Now given the screencapture, the error code does not look like a Creo error.
Do you have a mean to test your connexion to the Creo session? other than with this code?


Hey Remy,


thanks alot to jumping in.

what i feel is that creo is not able to connect with vb api..below is error i see




21-Topaz I

indeed connexion fails.


Did you search the knowledge base with IpfcAsyncConnection? A number of articles have been written ranging from changing PATH env var to settings in Visual Studio:



alternatively do you have benchmark VB application that connect to Creo? 




Thanks...gonna look those article right away.


and for vb i am using Microsoft excel. 

5-Regular Member


Long time before i worked on this area. Here is a code snippet which converts drw to pdf.

Sub Main()

Dim asyncConnection As pfcls.IpfcAsyncConnection = Nothing 'conn

Dim cAC As pfcls.CCpfcAsyncConnection

Dim session As pfcls.IpfcBaseSession

Dim tModel As pfcls.IpfcModel


 cAC = New pfcls.CCpfcAsyncConnection 'asynconn

 cAC = CreateObject("pfcls.pfcAsyncConnection")

 asyncConnection = cAC.Connect("", "", "", 5)

 session = asyncConnection.Session

Dim descModel As pfcls.IpfcModelDescriptor

Dim expdf As pfcls.IpfcPDFExportInstructions

Dim pdfopt As pfcls.IpfcPDFOption



 descModel = (New pfcls.CCpfcModelDescriptor).Create(pfcls.EpfcModelType.EpfcMDL_DRAWING, "test.drw", Nothing)

 expdf = (New pfcls.CCpfcPDFExportInstructions).Create()

 pdfopt = (New pfcls.CCpfcPDFOption).Create()

 pdfopt.OptionValue = (New pfcls.CMpfcArgument).CreateBoolArgValue(EpfcPDFOPT_LAUNCH_VIEWER)

 expdf.FilePath = "c:\work\test.pdf"

 tModel = session.CurrentModel

tModel.Export("c:\work\test.pdf", CType(expdf, pfcls.IpfcExportInstructions))

Catch ex As Exception

 MsgBox(ex.Message.ToString + Chr(13) + ex.StackTrace.ToString)



End Try

End Sub




any idea why this code showing red highlighted(not working) 


While similar, VB is not VBA. Excel uses VBA. When translating VB examples into VBA, you will need to translate the code to work in VBA. Examples:

  • When defining object variables you need to add Set cAC = New CCpfcAsyncConnection. This isn't required when using simple variables like strings, integers, boolean, etc.
  • When trying to execute tModel.Export() you need to add Call tModel.Export(). However, it seems to be inconsistent when adding this is required. For example, when using CreoWindow.Activate it is not required.
  • Some VB commands aren't supported in VBA.
    • Try/Catch is not available in VBA. You will have to use the VBA On Error GoTo
    •  Ctype is not available in VBA. In VBA, Dim two separate variables and Set one object type equal to a different object type to convert. Example:
      • Dim model As IpfcModel
        Dim solidMdl As IpfcSolid
        Set model = session.CurrentModel
        Set solidMdl = model

Thank for tour reply bro!!

my main concern right now is , i am not able to connect creo with vb abi. i have done pro_comm_msg.exe pvariable set, vb_register.bat also ran, ticked on vb referancing in excel. still not able to connect creo with vb api.

You may need to run vb_register.bat using right click>run as admin.

@Ketan_Lalcheta @NM_9425708 @HanSolo97 @RPN @lhoogeveen  if you guys could resolve my issue?


At the end it is Toolkit, did you add PRO_COMM_MSG_EXE to the System variables and you run vb_api_register.bat?

No connection if path to pro_comm_msg is not specified. 


yes bro that is done. i can also see vb reference in excel. but dont know why i am not able to connect. could you please help me further.

just to let you know nmsd.exe not running. how can i make that run. i try double clicking on that but didn't worked

@Ragnarok8979  could you please try the below ?

1) Start Creo Parametric with elevated previlages .Use Run as Administrator or start parameteric.exe from a command prompt window that is launched as 'Run as Admin'

2) Start MS Excel application also as "Run as Administrator"

3) Now try executing your VBA Excel script and see if the connection succeeds.

4) Also, try changing the line Set asyncConnection = cAC.Connect(Null, Null, Null, 50) 'this mean that try attempting to connect to Creo for 50 seconds.