Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old January 30th, 2007, 09:05 AM
Authorized User
 
Join Date: Jan 2007
Location: , , .
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


Reply With Quote
  #2 (permalink)  
Old January 30th, 2007, 09:12 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: London, , United Kingdom.
Posts: 173
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Dim dblShellRetn As Double

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

Reply With Quote
  #3 (permalink)  
Old February 1st, 2007, 05:57 AM
Authorized User
 
Join Date: Jan 2007
Location: , , .
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
Reply With Quote
  #4 (permalink)  
Old February 1st, 2007, 06:08 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: London, , United Kingdom.
Posts: 173
Thanks: 0
Thanked 2 Times in 2 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

Reply With Quote
  #5 (permalink)  
Old February 6th, 2007, 08:02 AM
Authorized User
 
Join Date: Jan 2007
Location: , , .
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
Reply With Quote
  #6 (permalink)  
Old February 6th, 2007, 08:06 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: London, , United Kingdom.
Posts: 173
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Have you added the reference?

Reply With Quote
  #7 (permalink)  
Old February 6th, 2007, 12:49 PM
Authorized User
 
Join Date: Jan 2007
Location: , , .
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
Reply With Quote
  #8 (permalink)  
Old February 6th, 2007, 01:12 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: London, , United Kingdom.
Posts: 173
Thanks: 0
Thanked 2 Times in 2 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

Reply With Quote
  #9 (permalink)  
Old February 7th, 2007, 07:33 AM
Authorized User
 
Join Date: Jan 2007
Location: , , .
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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
HOW to Run php program dimpleboy PHP How-To 6 January 30th, 2014 11:18 PM
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



All times are GMT -4. The time now is 12:16 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.