SolidWorks VBA Add a Sheet (MEP)

Hi all

I am looking to be able to automate a specific part drawing, and for the dimensioning of certain options I am looking to add a second sheet to insert an image.

I used macro recording and it gave me this:

Dim swApp As Object
Dim Part As Object
Dim SelMgr As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim Feature As Object
Sub main()

Set swApp = Application.SldWorks

Set Part = swApp.ActiveDoc
Set SelMgr = Part.SelectionManager
Part.NewSheet3 "Sheet2", 12, 12, 2, 1, True, "C:\Basemap\A4V_vide.slddrt", 0.21, 0.297, "Default", True
Dim SkPicture As Object
Set SkPicture = Part.SketchManager.InsertSketchPicture("C:\Users\IMG OPTIONS\U01.jpg")
End Sub

 

But once I add it to my macro an error message appears: "Invalid number of arguments or invalid property assignment (error 450) "

I don't see exactly where the problem comes from so if anyone has a solution I'm all ears.

Thanks in advance

Hello

there is one "True" too many. Try removing the last "True" in the definition of Part.NewSheet3

IDrawingDoc
Dim Name As String
Dim PaperSize As Integer
Dim TemplateIn As Integer
Dim Scale1 As Double
Dim Scale2 As Double
Dim FirstAngle As Boolean
Dim TemplateName As String
Dim Width As Double
Dim Height As Double
Dim PropertyViewName As String
Dim value As Boolean
 
value = instance.NewSheet3(Name, PaperSize, TemplateIn, Scale1, Scale2, FirstAngle, TemplateName, Width, Height, PropertyViewName)

 

 

 

Gauthik

 

 

3 Likes

Hello

You have to put a Boolean before Part.NewSheet3.

The correct rating is as follows:

Boolstatus = Part.NewSheet3 ("Feuille2", 12, 12, 2, 1, True, "C:\Fond de plan\A4V_vide.slddrt", 0.21, 0.297, "Par défaut")

 

3 Likes

Thank you both for your answers and your time, it's perfect.

I am applying it now

Sincere greetings

Be careful, you have to add a check on the name of the sheet:)