我复制的宏代码运行错误!!!跪求个SOLEDWORKS转DWG的宏文件,
错误的地方在下面红色地方,所以我求个SOLEDWORKS转DWG的宏文件,不要代码了,呵呵。有的传个给我,谢谢!
Dim swApp As Object
Dim Part As Object
Dim Filename As String
Dim No As Integer
Dim Title As String
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Filename = Part.GetPathName()
No = Len(Filename)
Filename = Left(Filename, No - 7)
Part.SaveAs2 Filename & ".DWG", 0, True, False
Title = Part.GetTitle
Set Part = Nothing
swApp.CloseDoc Title
X = MsgBox(" 已保存为 DWG 文件 ", 0)
End Sub
Dim swApp As Object
Dim Part As Object
Dim Filename As String
Dim No As Integer
Dim Title As String
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Part.SaveAs2 "C:\Documents and Settings\Administrator\桌面\工程图1" & ".DWG", 0, True, False
Title = Part.GetTitle
Set Part = Nothing
swApp.CloseDoc Title
MsgBox " 已保存为 DWG 文件 ", 0
End Sub
Dim swApp As Object
Dim Part As Object
Dim Filename As String
Dim No As Integer
Dim Title As String
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Filename = Part.GetPathName() 你这行获得的事全文件保存的全路径
No = Len(Filename) 这里你计算全路径的字符没有意义
Filename = Left(Filename, No - 7) no-7 更是不能达到你想要的文件名
Part.SaveAs2 Filename & ".DWG", 0, True, False 保存需要有全路径,而不是文件名
Title = Part.GetTitle
Set Part = Nothing
swApp.CloseDoc Title
X = MsgBox(" 已保存为 DWG 文件 ", 0)
End Sub