×
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

I have a macro that works if I have

I have a macro that works if I have

I have a macro that works if I have

(OP)
I have a macro that works if I have had something opened in the SolidWorks screen.  But if I try to run the macro first thing after starting SolidWorks the macro does not run. Is there something that I am missing?

Option Explicit
Dim swApp As Object
Dim Part As Object
Dim Gtol As Object
Dim FeatureData As Object
Dim Feature As Object
Dim Component As Object
Dim MyAppID, ReturnValue

Sub main()
     MyAppID = Shell("\\Athena\Eng\Applications\SolidWorks\Executables\OpenPDM.exe", 1)
End Sub

Bradley

RE: I have a macro that works if I have

Bradley

There is nothing wrong with your code. You can confirm that if you call another app. (excel for example). The macro will run even without an opened doc. I think the problem is on the app. itself. Mabe, when it starts, it will look for a doc. and stops on error because it can't find any. Have you tried to double click on the app., without a doc., to simulate the runing macro?

RE: I have a macro that works if I have

I am not familar with OpenPDM.exe. Does it require a  open document to run?

RE: I have a macro that works if I have

(OP)
This is the code for the OpenPDM.exe Which does run after I start a SolidWorks part, then close that part without saving. I put a shortcut OpenPDM.exe on my desktop and double clicked it.  The program does not start. The desktop shortcut does not start even if SolidWorks does have a document open. PushKeys work the same as SendKeys.  I learned about SendKeys from: http://www.nhcad.com/old/html/sendkeys.asp
I cannot for the life of me remember where I learned about PushKeys.

Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Declare Sub PushKeys Lib "KeyPush" (ByVal Keystrokes As String)
Dim swApp As Object
Dim Part As Object

Private Sub Form_Load()
    PushKeys "%F/{tab}"
        Unload Me
        End
End Sub

Bradley

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