excel - 错误 91,VBA Excel,CATIA API:未设置变量
问题描述
我正在尝试访问 CATIA 函数以在 Excel 宏中更新 Smarteam 中的文档生命周期,以下几行
Dim CATEngine As StiEngine
Set CATEngine = CATIA.GetItem("CAIEngine")
不断返回error 91: variable not set
问题。
从这个链接我不是为什么像这样的简单命令会返回这个错误 http://catiadoc.free.fr/online/interfaces/interface_StiEngine.htm
也许我没有正确加载某些库/集成?欢迎所有见解
这是来自其他模块的代码,非选项显式和非全局定义(我尝试了全局定义 CATIAEngine,但它返回歧义错误):
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
解决方案
推荐阅读
- php - codeIgniter 4中的force_download方法的等价物是什么
- flutter - Dart,在列表项上同时比较两种情况
- python - 画布上的 tkinter 菜单栏
- swift - SwiftUI:创建下拉菜单
- r - 在 R 中重命名和重新排序按时间顺序排列的 Excel 文件
- python - 使用 pyinstall 创建 exe 文件时出错,最后一个错误:'ImportError: Unable to load module attribute'
- apache-nifi - 如何使用 Nifi 流以“yyyyMMddHHmmss”或“yyyy-MM-dd HH:mm:ss”格式插入日期参数到 Oracle sql?
- python - 通过分隔一列的多列条形图
- flutter - 即使在滚动时,如何使搜索栏浮动或粘在屏幕上?
- gatsby - 在 Gatsby 中按规格过滤产品