Skip to main content
10-Marble
July 31, 2018
Solved

VB API Set session mismatch error

  • July 31, 2018
  • 2 replies
  • 2603 views

Trying to launch Creo with Excel based macro, when it gets to the Set session=asyncConnection.session command, I receive a Run-time error '13': Type mismatch.  Pasted below, any help on why I am getting this error is appreciated

 

Sub CreoTest()
'
' CreoTest Macro
'

'

Dim asyncConnection As IpfcAsyncConnection
Dim cAC As New CCpfcAsyncConnection
Dim session As IpfcBaseSession
Dim descModel As IpfcModelDescriptor
Dim descModelCreate As CCpfcModelDescriptor
Dim model As IpfcModel
Dim workDir As String
Dim position As Integer
' On Error GoTo RunError
'======================================================================
'First Argument : The path to the Pro/E executable along with command
'line options. -i and -g flags make Pro/ENGINEER run in non-graphic,
'non-interactive mode
'Second Argument: String path to menu and message files.
'======================================================================
Set cAC = New CCpfcAsyncConnection
' Set asyncConnection = cAC.Connect(Null, Null, ".", 5)
Set asyncConnection = cAC.Start("C:\PTC\Creo 2.0\Parametric\bin\parametric.exe", ".")
' + " -g:no_graphics -i:rpc_input", ".")
Set session = asyncConnection.session
'======================================================================
'Get current directory
'Set it as working directory
'======================================================================
workDir = ActiveWorkbook.FullName
position = InStrRev(workDir, "\")

 

Best answer by mtonsager

Figured it out, needed to add pfcls. in my Dim commands

2 replies

16-Pearl
August 1, 2018

use

Set cAC As New CCpfcAsyncConnection

mtonsager10-MarbleAuthorAnswer
10-Marble
August 3, 2018

Figured it out, needed to add pfcls. in my Dim commands