Dim swapp As SldWorks.SldWorks

Dim PatFilePath As String

Dim part As SldWorks.PartDoc

 

Private Sub Command1_Click()

Set swapp = GetObject("D:\Program Files\SolidWorks Corp\SolidWorks\SLDWORKS.exe", "SldWorks.Application")

 

    If Err Then

    Set swapp = CreateObject("SldWorks.SldWorks")

        If Err Then

          MsgBox ("无法创建SolidWorks")

          Exit Sub

        Else

          swapp.Visible = True

        End If

    End If

    

    swapp.Visible = True

    

    PatFilePath = "c:\Agile\wspaces\Default\5090050031.SLDPRT "

    Set part = swapp.NewDocument(PatFilePath, 0, 0#, 0#)

    part.SaveToFile

    

End Sub

posted on 2011-12-13 23:11  joyopod  阅读(489)  评论(0编辑  收藏  举报