Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 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 Search this Thread Display Modes
  #1 (permalink)  
Old March 15th, 2007, 06:20 AM
Friend of Wrox
 
Join Date: Oct 2006
Location: Northampton, Northants, United Kingdom.
Posts: 115
Thanks: 0
Thanked 0 Times in 0 Posts
Default Shell

Can anyone shed light onto why the following doesn't work:

Shell "C:\Documents and Settings\My Name\My Documents\My Program\Test\Test Application v5.mdb"

I moved the target application to a folder, thinking that spaces or length of path might have an effect, but this didn't work either:

Shell "c:\test\test.mdb"

The error that I am getting is "Run-time error 5 : Invalid procedure call or argument"

Yet, the next one does work...

Shell "C:\program files\Microsoft Office 97\Office\MSACCESS.exe"

My conclusion is that you can only SHELL to an EXE ... terrible shame ... can anyone suggest an alternative to SHELL so that I can launch what I like?

Thanks in advance.

(Note: I cannot have references any components that are not standard with Windows, as we are not allowed to run installations to get the finished programs to work - literally copy the EXE to the customer PC and that's it).


[--- UPDATE ---]

Whilst I am still confused about the above, I have found the solution, as follows:

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

ShellExecute 0, vbNullString, "C:\Documents and Settings\My Name\My Documents\My Program\Test\Test Application v5.mdb", "", "c:\", vbMaximizedFocus
__________________
Regards,

Sean Anderson
Reply With Quote
  #2 (permalink)  
Old March 15th, 2007, 01:40 PM
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Think about what you are asking. Shell is used to load the contents of an executable file into RAM, and then point the microprocessor’s instruction pointer at the beginning of the part that contains instructions for the microporcessor.

An MDB contains the data that MSAccess.exe can process. The MDB contains [u]no instructions whatsoever for the microprocessor</u>.

A DOC file contains the data that MSWord.exe can process. The DOC contains no instructions whatsoever for the microprocessor, and hence cannot serve as the argument for a Shell statement which requires an "executable" file.

What would you like Shell to do when you use “Shell C:\<Path>\Test Application v5.mdb”?

(The database window is a construct of MSAccess.exe. There is no means in xxx.mdb to present the functionality that the DB Window gives. The same is true of Access’ menu system, reporting, VBA hosting, ad infinitim.)
Reply With Quote
  #3 (permalink)  
Old March 15th, 2007, 01:58 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Brian is quite right. But you could do something like this: (Example using word)

Shell("C:\program files\Microsoft Office\Office11\winword.exe path\to\document", 1)

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
Reply With Quote
  #4 (permalink)  
Old March 16th, 2007, 05:41 AM
Friend of Wrox
 
Join Date: Oct 2006
Location: Northampton, Northants, United Kingdom.
Posts: 115
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Because both the application and the file (to be opened) are known; it can be coded where I use lpParameters part of ShellEx.

Just sending an MDB file opens the database in Access with no problems, but as a business we work with three versions of Access (to match customer requirements) and the MDB opens in the last version of Access that you had running, which is very frustrating at times and this now means that I can load the MDB's in the appropriate versions, with:

ShellExecute 0, vbNullString, sAccess97Version, "c:\my97.mdb", "c:\", vbMaximizedFocus
ShellExecute 0, vbNullString, sAccess2000Version, "c:\my2000.mdb", "c:\", vbMaximizedFocus
ShellExecute 0, vbNullString, sAccess2003Version, "c:\my2003.mdb", "c:\", vbMaximizedFocus

Regards,

Sean Anderson
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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: Shell???? Apocolypse2005 Visual Basic 2005 Basics 1 April 24th, 2008 06:31 AM
shell trouble albertoaloe Beginning VB 6 5 July 29th, 2005 12:18 PM
Using the Shell Function RAPSR59 Access 1 April 13th, 2005 07:14 AM
Shell programming programmed C++ Programming 1 November 30th, 2003 07:10 AM
c-shell script timpeters C# 0 October 21st, 2003 12:08 AM



All times are GMT -4. The time now is 04:30 PM.


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