I'm trying to access CATIA functions in updating document life cycle in Smarteam in excel macro, the following lines
Dim CATEngine As StiEngine
Set CATEngine = CATIA.GetItem("CAIEngine")
keeps returning error 91: variable not set
issue.
From this link I'm not why a simple command like this is returning this error http://catiadoc.free.fr/online/interfaces/interface_StiEngine.htm
perhaps I'm not loading certain libraries/ integrations properly? all insights welcome
This is the code from other module that worked, non option explicit and non global definitions (i've tried global define CATIAEngine, but it returns ambiguity error):
Sub checkUUID()
Dim FoundObj As ISmObject
Dim wbNew As Workbook, wsNew As Worksheet
Dim checkDOCUUID As Document
Dim Products As Products
Set wbNew = ActiveWorkbook
Set wsNew = wbNew.Sheets(1)
Set SmEngine = CreateObject("SmApplic.SmFreeThreadedEngine")
SmEngine.Init "SmTeam32"
Set SmSession = CreateObject("SmApplic.SmSession")
SmSession.Init SmEngine, "MySession", "SmTeam32"
wsNew.Activate
Dim childList() As String
Set SmDatabase = SmEngine.Databases(0)
ID = SmDatabase.Alias 'Provider=SQLOLEDB.1;Persis Security Info=False;User ID=SMARTUSER;Initial Catalog=Smarteam;Data Source=ST2008SQL\SQLSMARTEAM
Pass = SmDatabase.Password 'ProvidSMARTEAM_7kikX/GtJNG6d7BcYeTi8cf4IuVCgWjDrvo/Oo4xdZgHjg+fDpzdEEll7tcGT96tcB7pP8krz1hw6pDgzXchTrwfm1t0FKGsDK6C7EvQW7+grVLwZamcVpnmz6ibMWAogHWcLM+H6ID87NIXwBLXNaJxm3tKg6eZ84nzNSkCGFc=
Call SmSession.OpenDatabaseConnection(ID, Pass, True)
If SmSession.IsServiceEnabled("SmGUISrv.SmCommonGUI", Reason) Then
Set GUIServices = SmSession.GetService("SmGUISrv.SmCommonGUI")
End If
GUIServices.Dialogs.ExecuteLogin
Set FSO = CreateObject("Scripting.filesystemobject")
tempFolderName = "C:\ST Temp\UUID\"
If Len(Dir("C:\ST Temp\", vbDirectory)) = 0 Then
MkDir "C:\ST Temp\"
End If
If Len(Dir("C:\ST Temp\UUID\", vbDirectory)) = 0 Then
MkDir tempFolderName
End If
CatiaConnect 'launch Catia V5
CatIntgConnect 'connect to ST using ST CATIA integration
CATIA.DisplayFileAlerts = False 'disable all the warning's and disables all the user interaction
CatIntgConnect
Sub CatIntgConnect()
Set CATEngine = CATIA.GetItem("CAIEngine")
' -----------------------------------------------------------
' CATIA V5 Operations are performed in the background
' -----------------------------------------------------------
Dim BooleanUI As Boolean
If (CATEngine.UseGraphicalUI) = True Then
CATEngine.UseGraphicalUI = True
BooleanUI = True
End If
' -----------------------------------------------------------
' Connect to the SmarTeam database (if not already connected)
' -----------------------------------------------------------
Dim BoolConnect As Boolean
BoolConnect = False
If Not CATEngine.IsConnected() = True Then
CATEngine.Connect "", "" 'to perform automation via CATIA SMARTEAM integration, must type in the userid and password
BoolConnect = True
End If
End Sub