I have this macro to replace the sheet format. There is no error to run it; however, the active sheet format (actually the title block) is not replaced by the one in c:\temp
Thx
Public swApp As SldWorks.SldWorks
Public swModel As SldWorks.ModelDoc2
Public swDraw As SldWorks.DrawingDoc
Public swSheet As SldWorks.Sheet
Public Const sTemplatePath As String = "c:\temp\"
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
If (swModel Is Nothing) Then
MsgBox "No active drawing found in SolidWorks." & Chr(13) & Chr(13) _
& "Please Open a SolidWorks drawing ", vbExclamation
End
End If
If (swModel.GetType <> swDocDRAWING) Then
MsgBox "Current document is not a drawing." & Chr(13) & Chr(13) _
& "Please Open a SolidWorks drawing ", vbExclamation
End
End If
Set swDraw = swModel
Set swSheet = swDraw.GetCurrentSheet
Dim aProps As Variant
Dim ScaleNumerator As Double
Dim ScaleDenominator As Double
aProps = swDraw.GetCurrentSheet.GetProperties
ScaleNumerator = aProps(2)
ScaleDenominator = aProps(3)
'MsgBox (ScaleNumerator, " ", ScaleDenominator)
Dim bRet As Boolean
Dim sPath As String
sPath = sTemplatePath & "B_Size_TitleBlock.slddrt"
bRet = swDraw.SetupSheet4(swSheet.GetName, swDwgPaperBsize, swDwgTemplateCustom, ScaleNumerator, ScaleDenominator, False, sPath, 0.4318, 0.2794, "Default")
swModel.ForceRebuild3 (False)
Set swApp = Nothing: Set swModel = Nothing: Set swDraw = Nothing: Set swSheet = Nothing
End Sub