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

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

Looking for answers in connecting to a Creo Session using Excel VBA


Looking for answers in connecting to a Creo Session using Excel VBA

Hi. I've been battling this issue for quite a while now, and I can't sesem to find adequate answers to help me with this. (I've spent hours browsing through documents and on the net.) I seem to be stuck at one point in my code, (in vba excel) regardless of the example code that I've used and it is with the

CCpfcAsyncConnection.Connect() method. For one thing, I don't understand the arguments that are required. (I'm unable to find any explanation as to what the correct values should be for the arguments; Display, UserID, TextPath, TimeoutSec. Most of the examples I have seen use a null value, e.g

Set cAC = New CCpfcAsyncConnection

Set asyncConnection = cAC.Connect(dbnull, dbnull, dbnull, dbnull) or the dbnull is replaced with "DBnull.value."

In any event, this is where I'm stopped in my efforts to connect to a current Pro/E session. The error msg is always the same - "pfcExcpetions::XToolkitCantModify." I only have a single session open with a single part, and I have no other threads tied to it (as far as I know). I have set the PFCLS_START_DIR environment variable to \x86e_win64\obj\ ,and I have set the PRO_COMM_MSG_EXE environment variable to \x86e_win64\obj\. I also have the PRO_DIRECTORY environment variable set to C:\%\Creo 2.0\. (I don't know that this variable shouldn't be set to the xtop.exe directory.) And I have executed the vb_api_register batch file as administrator. (I have even run the batch file from the command window after removing the @echo off to watch the command flow.) As far as I can tell, I have jumped through all of the hoops. What am I doing wrong?? I just can't imagine that this should be this difficult. I have also tried an example in Visual2010 on another machine without much luck. I'm trying to do this in Windows 7 on a 64 bit intel machine, Creo Parametric 2.0, and with Excel 2010. Any suggestions would be appreciated. (I don't have access to the PTC eSupport, so I cannot use any links to that service.) Thanks!!


Perpetually Frustrated.

This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.

I have discovered that the XToolkitCantModify error indicates that "The model is locked and can not be modified." Is there something in the model or Creo session that needs to be manipulated to make the model available for modification from an external thread?

I have tried this sample code, which seems fairly straightforward, and I still have the same result;

Sub Macro1()

Dim asynconn As New pfcls.CCpfcAsyncConnection

Dim conn As pfcls.IpfcAsyncConnection

Dim session As pfcls.IpfcBaseSession

Dim mdlname

Set conn = asynconn.Connect("", "", ".", 5)

Set session = conn.session

mdlname = session.CurrentModel.Filename


ActiveCell.FormulaR1C1 = mdlname

MsgBox ("Name: " & mdlname)

conn.Disconnect (2)

End Sub

Well, I found the answer to my immediate problem, and I'm posting the remedy here for posterity's sake. I had to run the batch file protk_unlock.bat for the version of Creo that I'm working in. That batch file runs the executable of the same name. Apparently this unlocks Pro/Toolkit. I was able to access and subsequently update the simple model that I had open in Creo. This is a caveat that really should have been in the documentation for implementing the VBA API. (Does PTC really want an aggravation free environment that encourages using the programming API's with Creo?)


Hi John, there is not much information about VB API on the web, so I published some examples in this blog: Creo Automation, perhaps could be helpful for you.

John, We may be able to help you out if we understand more fully what you are trying to accomplish.  Simplified Logic Inc specializes in bi-directional Excel to Creo or Creo to Excell data transfer this with an application called Nitro-CELL.  Please see this Website: Simplified Logic, Inc. and YouTube Channel:  Simplified Logic, Inc. - YouTube

Hello John,

You are Environment variable setting is wrong, please change to PRO_COMM_MSG Instead of PRO_COMM_MSG_EXE. F083A0F3-0145-407A-BF28-4FD8ABCAAB86.png

If above trick not working

You set Both user & system variables for



Top Tags