GetOpenDocumentByName ------------- Not open File,Solidowrks file established and communications.
Function SetSwNamePart(FileName)
Dim SwApp As Object
Dim SelMgr As Object, boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Set SwApp = GetObject(, "sldworks.application")
'Debug.Print IsNull(swApp)
Set SetSwNamePart = SwApp.GetOpenDocumentByName(FileName)
'swApp.Visible = True
End Function
-------
OpenDoc6-----Must file open, and establish communication with solidowrks
Function SwOpenFile(SwApp, OpenFile)
'Debug.Print OpenFile
' SwApp.Visible = True
Dim SwPart As Object
Dim nDocType As Long
Dim nErrors As Long
Dim nWarnings As Long
Dim swOpenDocOptions_Silent
swOpenDocOptions_Silent = 1
' Determine type of SolidWorks file based on file extension
If InStr(LCase(OpenFile), "sldprt") > 0 Then
nDocType = 1 'swDocPART
ElseIf InStr(LCase(OpenFile), "sldasm") > 0 Then
nDocType = 2 'swDocASSEMBLY
ElseIf InStr(LCase(OpenFile), "slddrw") > 0 Then
nDocType = 3 'swDocDRAWING
Else
' Probably not a SolidWorks file...
nDocType = swDocNONE
'...so the file cannot be opened
Exit Function
End If
''
'Set SwPart = SwApp.OpenDoc6(OpenFile, nDocType, _
swOpenDocOptions_Silent, "", nErrors, nWarnings)
'Set SwPart = SwApp.OpenDoc6(OpenFile, 1, 1, "", nErrors, nWarnings)
Set SwOpenFile = SwPart
'Debug.Print SwPart.GetPathName
End Function