Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

Solidworks Macro Help

Status
Not open for further replies.

stewpart

Industrial
Oct 3, 2008
2
0
0
US
Recently my Macros stopped working, we did not even upgrade SW or anything, here is one below for adding custom properties to parts, I get the wonderful 91 error and it highlights

retval = Part.AddCustomInfo3("", MyProp(0, m), 30, _
MyProp(1, m))

each time. What the hell!See macro below:

Sub main()

Set swApp = CreateObject("SldWorks.Application")
Set Part = swApp.ActiveDoc

Dim MyProp(1, 16) As String

'Property names

MyProp(0, 0) = "Description"
MyProp(0, 1) = "PartNo"
MyProp(0, 2) = "Revision"
MyProp(0, 3) = "Material"
MyProp(0, 4) = "Weight"
MyProp(0, 5) = "DrawnBy"
MyProp(0, 6) = "DrawnDate"
MyProp(0, 7) = "Client"
MyProp(0, 8) = "Material Spec"
MyProp(0, 9) = "Blank L"
MyProp(0, 10) = "Blank W"
MyProp(0, 11) = "RH PART"
MyProp(0, 12) = "LH PART"
MyProp(0, 13) = "PART"
MyProp(0, 14) = "PART OF WLDMT"
MyProp(0, 15) = "QTY PER"
MyProp(0, 16) = "FILE LOCATION"

'Property values

MyProp(1, 0) = "PART DESCRIPTION"
MyProp(1, 1) = "$PRP:" & Chr(34) & "SW-File Name" & Chr(34)
MyProp(1, 2) = "1"
MyProp(1, 3) = " " & Chr(34) & "SW-Material" & Chr(34)
MyProp(1, 4) = " " & Chr(34) & "SW-Mass" & Chr(34)
MyProp(1, 5) = "SWP"
MyProp(1, 6) = Date
MyProp(1, 7) = "CUSTOMER"
MyProp(1, 8) = "SIZE AND GRADE"
MyProp(1, 9) = "L"
MyProp(1, 10) = "W"
MyProp(1, 11) = "XXXXX"
MyProp(1, 12) = "XXXXX"
MyProp(1, 13) = "SHOWN"
MyProp(1, 14) = "PART OF WLDMT"
MyProp(1, 15) = "QTY PER"
MyProp(1, 16) = "_"

Dim m As Integer

For m = 0 To 16
retval = Part.AddCustomInfo3("", MyProp(0, m), 30, _
MyProp(1, m))
Next m

End Sub
 
Replies continue below

Recommended for you

Works fine for me. Maybe try finding a computer that these macros still work on, and Copy it's SW Library file over your's that aren't working?..maybe?
 
Status
Not open for further replies.
Back
Top