Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X
Hi all~
I am a beginner of PROE.
I've been trying to connect creo parametric by using Excel VBA.
Below is my sample code.
Dim asyncConnection As IpfcAsyncConnection
Dim cAC As CCpfcAsyncConnection
Dim session As IpfcBaseSession
Dim descModel As IpfcModelDescriptor
Dim descModelCreate As CCpfcModelDescriptor
Dim model As IpfcModel
Dim workDir As String
workDir = "C:\Program Files\Creo 2.0\Parametric\bin\parametric.exe"
Set cAC = New CCpfcAsyncConnection
Set asyncConnection = cAC.Start(workDir, "Working Directory")
And then, I got an run time error like below.
run-time error -2147352567(80020009)
pfcExceptions::XToolkitGeneralError
What is this error, and how to resolve this error?
I don't use VBA, so I can't test your code myself.
Here is what I found in the Creo Parametric VBAPI documentation:
'======================================================================
'First Argument : The path to the Creo Parametric executable along with command
'line options. -i and -g flags make Creo Parametric run in non-graphic,
'non-interactive mode
'Second Argument: String path to menu and message files.
'======================================================================
Set cAC = New CCpfcAsyncConnection
Set asyncConnection = cAC.Start(txtExePath.Text + " -g:no_graphics -i:rpc_input", ".")
The second argument should be the name of a directory (folder), like "C:\Program Files\Creo 2.0\Parametric".
The example above uses the directory ".", which is the current working directory that the program is running in.
That works only if you launch the program from the directory that contains menu and message files.
In your code, you use the string "Working Directory":
Dim workDir As String
workDir = "C:\Program Files\Creo 2.0\Parametric\bin\parametric.exe"
Set cAC = New CCpfcAsyncConnection
Set asyncConnection = cAC.Start(workDir, "Working Directory")
The directory name "Working Directory" is almost certainly incorrect. I believe this is the reason why your program crashed.
You also used the variable named "workDir" to contain the pathname of Creo Parametric. That won't cause a crash, but it will confuse anyone who reads the program, including yourself .
|+| M a r k |+|