Reloading Sheet format with API

Hi

I've been tring to reload a sheet format using the API but it doesn't appear to work - no error messages just doesn't do it . What am I missing?

Dim swApp As Object Dim Part As Object Dim boolstatus As Boolean Dim longstatus As Long Dim Annotation As Object Dim Gtol As Object Dim DatumTag As Object Dim FeatureData As Object Dim Feature As Object Dim Component As Object Sub main()

Set swApp = Application.SldWorks

Set Part = swApp.ActiveDoc Part.SetupSheet4 "Sheet1", 6, 12, 1, 1, False,_ "G:\SolidWorks\Sheet Formats\STA4 2004.slddrt", 0.297, 0.21, "Default" Part.EditSketch End Sub

Cheers

Craig

Reply to
Craig T
Loading thread data ...

I think your paper size constants are wrong

Your code

Part.SetupSheet4 "Sheet1", 6, 12, 1, 1, False,_

My code that works Part.SetupSheet4 "Sheet1", 1, 1, 1, 1, False, "B portrait.slddrt", 0.297,

0.21, "Default"

Look in the swconst.bas for details on the constants. Also it may cause problems to split the code line. If the sheet name is different i.e. "sheet 2" the code would not work.

Goood luck

Warren

Reply to
Warren

'this has been tested and it works. make sure STA4 2004.slddrt is in folder 'G:\SolidWorks\Sheet Formats.

'hope this helps you out.

Option Explicit

Dim swApp As SldWorks.SldWorks Dim Part As Object

Sub main()

Set swApp = New SldWorks.SldWorks Set Part = swApp.ActiveDoc Part.SetupSheet4 "Sheet1", 6, 12, 1, 1, False, _ "G:\SolidWorks\Sheet Formats\STA4 2004.slddrt", _

0.297, 0.21, "Default" Part.EditSketch End Sub

Reply to
Sean Phillips

Found my problem, the sheet format file name must be different from the existing one to trigger a reload. (I was trying to reload the old sheet format again). If you want to do that you can use

Sheet.SetTemplateName "Some dummy name" Part.SetupSheet4 "Sheet1", 6, 12, 1, 1, False, _ "Old sheet format file and path", _ 0.297, 0.21, "Default"

Craig

Reply to
Craig T

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.