Vba Component.Replace的正确语法是什么?

Vba Component.Replace的正确语法是什么?,vba,autodesk,Vba,Autodesk,以下是我被告知的访问Inventor“替换零部件”命令的正确方法: 但是我有一个语法错误。正确的语法是什么?我没有在Inventor VBA库中看到它 OldNamePath和NewNamePath来自创建完整路径名的不同模块 我得到的错误是“Expected=”error…,我相信这就是iLogic的语法 有一个组件发生。请根据编程帮助文件进行替换 它还包含添加新事件和操作现有事件的示例。” 来自Autodesk Inventor自定义论坛 还有。。。 “您是从iLogic还是VBA宏执行此操

以下是我被告知的访问Inventor“替换零部件”命令的正确方法:

但是我有一个语法错误。正确的语法是什么?我没有在Inventor VBA库中看到它

OldNamePath和NewNamePath来自创建完整路径名的不同模块

我得到的错误是“Expected=”error…

,我相信这就是iLogic的语法

有一个组件发生。请根据编程帮助文件进行替换

它还包含添加新事件和操作现有事件的示例。”

来自Autodesk Inventor自定义论坛

还有。。。 “您是从iLogic还是VBA宏执行此操作。如果您是从iLogic执行此操作,则命令为Component.Replace,但参数为:

Component.Replace(componentName, newPath, False) with componentName being the name of the component in the assembly.
如果是从VBA宏执行此操作,则需要设置要更改的组件的ComponentOccurrance对象

Dim occ as ComponentOccurrance

Set occ = (the component occurrance object you want to replace)



//To replace

occ.Replace(newPath, False)"
第三个答复:

"

Public Sub-CReplace()
作为成分出现的暗淡的oOccurrence
Set oOccurrence=ThisApplication.ActiveDocument.ComponentDefinition.occurrence.Item(1)
o发生。替换“”,正确
端接头
"

Dim occ as ComponentOccurrance

Set occ = (the component occurrance object you want to replace)



//To replace

occ.Replace(newPath, False)"
Public Sub CReplace()

Dim oOccurrence As ComponentOccurrence
Set oOccurrence = ThisApplication.ActiveDocument.ComponentDefinition.Occurrences.Item(1)
oOccurrence.Replace "<filename>", True


End Sub