【发布时间】:2014-10-10 16:53:15
【问题描述】:
在 Solidworks 中我录制了两个宏。
宏 1 为空:
Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
'added code
Dim distance_of_second_plane
'end of added code
Sub main()
Set swApp = _
Application.SldWorks
Set Part = swApp.ActiveDoc
'added code: here I want to call the second macro and send it distance_of_second_plane, and have it use that value
distance_of_second_plane = .05
'.. now what?
'end of added code, don't know what to add.
End Sub
宏 2 需要来自宏 1 的数据:
Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Sub main()
Set swApp = _
Application.SldWorks
Set Part = swApp.ActiveDoc
boolstatus = Part.Extension.SelectByID2("Front Plane", "PLANE", 0, 0, 0, True, 0, Nothing, 0)
Dim myRefPlane As Object
Set myRefPlane = Part.FeatureManager.InsertRefPlane(8, 0.05334, 0, 0, 0, 0)
Part.ClearSelection2 True
End Sub
这些宏当然保存在不同的文件中。如何从第一个调用第二个,从第一个传入数据,并在第二个中使用它?
我尝试过的东西:http://support.microsoft.com/kb/140033、http://www.cadsharp.com/macros/run-macro-from-another-macro-vba/、VBA module that runs other modules、Call a Subroutine from a different Module in VBA
所有这些都是有问题的。如果需要,我会详细说明我遇到的错误。
【问题讨论】:
标签: vba solidworks