Wrox Programmer Forums
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 30th, 2007, 10:05 AM
Authorized User
 
Join Date: Jan 2007
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default run a program with VBA

Hi to all,

I am trying to open SAS with VBA.
the file is in y:/my documents/simulator.sas
Does anybody know what type of instruction I should use?

Many thanks,
Wim


 
Old January 30th, 2007, 10:12 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 173
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Dim dblShellRetn As Double

dblShellRetn = Shell("y:/my documents/simulator.sas", vbNormalFocus)

 
Old February 1st, 2007, 06:57 AM
Authorized User
 
Join Date: Jan 2007
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks for your help, but it doesn't seem to work.
I get an error message "invalid procedure call or argument"
Greetz,
Wim
 
Old February 1st, 2007, 07:08 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 173
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Sorry - should have said that you need to add a reference to "Microsoft Shell Controls and Automation" (Tools -> References... in the VBE)

Maccas

 
Old February 6th, 2007, 09:02 AM
Authorized User
 
Join Date: Jan 2007
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi Maccas,
I still have the same error message.
This is what I did so far....

Sub opensas()
Dim dblShellRetn As Double
dblShellRetn = Shell("y:/my documents/test.sas", vbNormalFocus)
End Sub

Thanks,
Wim
 
Old February 6th, 2007, 09:06 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 173
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Have you added the reference?

 
Old February 6th, 2007, 01:49 PM
Authorized User
 
Join Date: Jan 2007
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Maccas
I just checked that Microsoft Shells controls etc. was turned on.
Hope that was what you meant by adding the reference. Or should it be somewhere in the code? In that case I wouldn't know how to do that.
greetz,
Wim
 
Old February 6th, 2007, 02:12 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 173
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Well then, I'm a bit confused as that command always works for me. I'm not 100% sure you've got the reference linked up ok but it sounds like you've done it right. Forgive me if this is preaching to the converted but for avoidance of confusion, the following process you implement to add a reference to your VBA project:

1) Go to the VBE (Visual Basic Editor) i.e. the window with your VBA code in.
2) Ensure you are looking (have active) at a code pane of the project you want to add a reference to. e.g. looking at the problematic code will work. Note if you don't ensure this step you'll add a reference to the wrong project and the error will remain.
3) Click on the Tools menu.
4) Select the first menu option, References...
5) This will open up a dialogue box with a sub-window with lots of checkbox items in it.
6) Scroll down the list to an item called "Microsoft Shell Controls and Automation" and check it.
7) Click ok on the dialogue box.
8) You've added the reference.

If this doesn't work then I'm out of ideas - sorry! You could always try Google for cases of Shell not working for launching apps.

Maccas

 
Old February 7th, 2007, 08:33 AM
Authorized User
 
Join Date: Jan 2007
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I googled a bit...
http://support.microsoft.com/kb/149570
"Only files that have an .exe, .com or .bat extension can be executed through the Shell function."
This can explain the problem perhaps.
Wim





Similar Threads
Thread Thread Starter Forum Replies Last Post
HOW to Run php program dimpleboy PHP How-To 7 January 22nd, 2015 12:40 AM
program compiles but won't run jwg Visual C++ 0 July 10th, 2008 09:42 AM
Error when trying to run program. Asp_Developer ASP.NET 2.0 Basics 1 May 21st, 2008 06:04 AM
How to run another .exe from my program shivendra C++ Programming 1 July 28th, 2006 04:56 AM
Run program from another computer ngthhoang Visual C++ 3 June 27th, 2004 04:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.