Files
Open document and create new window
Code
'Create new window for opened document
'Precondition: make sure that strFilePath is pointing to an existing file
'Written by Keith Rice
'CADSharp LLC
'www.cadsharp.com
Option Explicit
Const strFilePath As String = "C:multibody.sldprt"
Dim swApp As SldWorks.SldWorks
Dim swPart As SldWorks.ModelDoc2
Dim fileerror As Long
Dim filewarning As Long
Sub main()
Set swApp = Application.SldWorks
swApp.Visible = True
swApp.OpenDoc6 strFilePath, swDocPART, swOpenDocOptions_Silent, "", fileerror, filewarning
swApp.CreateNewWindow
swApp.ArrangeWindows 1
Set swPart = swApp.ActiveDoc
'MsgBox swPart.GetTitle
swPart.ShowNamedView2 "*Isometric", -1
End Sub
' ArrangeWindows arguments:
' 0 = Cascade
' 1 = Tile horizontally
' 2 = Tile vertically
'REMARKS ON OPENDOC6
'Using OpenDoc6 you will always have a pointer to the document.
'OpenDoc6 by itself will open the document, however to access the doc with the
'API you must still set a model object equal to it.
'You can use either to access the document:
'Set swPart = swApp.OpenDoc6 ...
' -OR-
'swApp.OpenDoc6
'Set swPart = swApp.ActiveDoc
'If you run OpenDoc6 on the same part twice, only one instance (and therefore
'one window) will exist of that part.
'Use swApp.CreateNewWindow to create another window of that document. This will
'be the new active doc.