×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Solidworks Macro Help

Solidworks Macro Help

Solidworks Macro Help

(OP)
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

RE: Solidworks Macro Help

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?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources