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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Macro + VBScript Error Help

Status
Not open for further replies.

rswarich

Technical User
Jun 7, 2001
7
US
Hello,
We are writing a VB macro in Excel that needs to
open a file in another application and do some
processing there. Having problems getting the other application to open reliably.

Two approaches were tried, each had problems:
1. The preferred method has the following code placed directly in the VB Excel macro. Sometimes it works and other times it gives a VB error about the method "run"
not being valid. Can anyone suggest what is wrong with
this code or another way to open a file in another application from within a VB Excel macro?

2. The other way is to have the following code in a separate VBscript file and then use shell command from within the VB Excel macro to launch that VBscript. This also did not always work, and there is the problem of having the separate VBscript file to worry about.


Dim ss
Set ss = CreateObject("WScript.Shell")
ss.run mypath + "\sw_i_6.sldprt", 1


Thank you
 
Hi

I could not replicate your problem and your code looks fine and works well.

I would suggest adding

set ss = Nothing

to the end. Also keep an eye on what you are passing in as "mypath"

Good luck

-Sunny
 
VBScript and VBScript for applications (VBA) operate a little different. WshShell calls don't work consistently in VBA (it probably depends on the version). If you are having trouble using it, try just using Shell.
Ex:
Shell mypath + "\sw_i_6.sldprt", vbNormalFocus

The main difference is, I don't think this will handle command line switches, and the script will not wait for the completion of this application before it continues.

Dana Hallenbeck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top