×
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

Declaring Variables in a macro

Declaring Variables in a macro

Declaring Variables in a macro

(OP)
Maybe I have missed something in the API help files, but when I try to set a variable like so:

Dim swApp                   As SldWorks.SldWorks

I get an error.  Why not set is as an object you may ask.  It works that way, but all of the SW API help files have it listed as above but I cant get it to work.  Any insight?

Thanks,
Brian

RE: Declaring Variables in a macro

That way works for me.

Perhaps your VBA install is self-destructing, guessing from your previous recent posts.

Otherwise, make sure the macro is referencing the SW type library.  If the macro started life recorded from SW, this shouldn't be a problem.

Due to illness, the part of The Tick will be played by... The Tick.
http://www.EsoxRepublic.com

RE: Declaring Variables in a macro

(OP)
I think you are right Tick, this is getting out of hand.  I have noticed that if I simply restart my computer everything works again, go figure.

RE: Declaring Variables in a macro

Creigbm

When you are editing a macro, in the VBA environment, go to Tools\References.

Check if the box Sldw 2004 type library is selected. If not, VBA will fail to recognize some API from Solidworks.

Good Luck

RE: Declaring Variables in a macro

(OP)
Bingo..Thanks macPT, that worked.

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