AnsweredAssumed Answered

Sheet Swap Maintain Scale and Sheet Name

Question asked by Michael Deleo on May 17, 2018
Latest reply on May 18, 2018 by Matt Peneguy

Hello,

We have been using a sheet swap macro for years. We found that this macro actually renames the sheets to Sheet1 this has unintended consequences when making PDFs.

 

Please help us modify this code so the sheets keep the name they had before the macro is run. I have tried using SheetName in  place of "Sheet1" the code doesn't error but it also doesn't run.

 

Thank You in advance

Mike

 

' ******************************************************************************

' C:\Users\deleom\AppData\Local\Temp\swx7152\Macro1.swb - macro recorded on 09/26/16 by deleom

' ******************************************************************************

Dim swApp As Object

 

Dim Part As Object

Dim boolstatus As Boolean

Dim longstatus As Long, longwarnings As Long

Dim Name1 As String

Dim Scale1 As Double

Dim Scale2 As Double

 

 

Sub main()

 

Set swApp = _

Application.SldWorks

 

Set Part = swApp.ActiveDoc

Dim myModelView As Object

Set myModelView = Part.ActiveView

myModelView.FrameState = swWindowState_e.swWindowMaximized

 

Scale1 = CurentScale1

Scale2 = CurentScale2

 

 

boolstatus = Part.Extension.SelectByID2("Annotations", "DCABINET", 0, 0, 0, False, 0, Nothing, 0)

boolstatus = Part.Extension.SelectByID2("Sheet1", "SHEET", 0, 0, 0, False, 0, Nothing, 0)

Part.ClearSelection2 True

boolstatus = Part.SetupSheet5("Sheet1", 12, 12, Scale1, Scale2, False, "BAX_D_ASSEMBLY.slddrt", 0.8636, 0.5588, "Default", True)

boolstatus = Part.Extension.SelectByID2("Sheet1", "SHEET", 0, 0, 0, False, 0, Nothing, 0)

Part.ClearSelection2 True

 

End Sub

Outcomes