Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TugboatEng on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

I have a macro that works if I have

Status
Not open for further replies.

Standing

Mechanical
Joined
Jan 14, 2002
Messages
1,578
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
 
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?
 
I am not familar with OpenPDM.exe. Does it require a open document to run?
 
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: 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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top