Hi - I've got a macro that we use when exiting a model to set to Iso View, Shaded with Edges, Zoom Fit, Save, and then close the document. I'm modifying it to work with a drawing also. This works great except that I'd like it to change the active sheet to sheet 1 with name of "BOM" prior to performing the ZoomFit and Save functions. I'm thinking I need to use the ActivateSheet command but I can't seem to get this work.
Any advice?
'Sets view to Iso, Shaded with Edges, Saves the active model and closes the window
Option Explicit
Public Enum swViewDisplayMode_e
swViewDisplayMode_Wireframe = 1
swViewDisplayMode_HiddenLinesRemoved = 2
swViewDisplayMode_HiddenLinesGrayed = 3
swViewDisplayMode_Shaded = 4
swViewDisplayMode_ShadedWithEdges = 5 ' only valid for a part
End Enum
Sub main()
Const nNewDispMode As Long = swViewDisplayMode_ShadedWithEdges
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swModView As SldWorks.ModelView
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swModView = swModel.ActiveView
If swModel.GetType = swDocPART Then
swModView.DisplayMode = nNewDispMode
Debug.Assert nNewDispMode = swModView.DisplayMode
swModel.ShowNamedView2 "*Isometric", 7
swModel.ViewZoomtofit2
swModel.Save
Else
swModel.ViewZoomtofit2
swModel.Save
End If
swApp.CloseDoc (swApp.ActiveDoc.GetPathName)
End Sub
