Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access 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
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 12th, 2005, 09:41 AM
Registered User
Join Date: Apr 2005
Location: El Paso, TX, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using the Shell Function

Subject: Access Shell function

In using the Shell function I am opening an existing Excel document using the following code:

strFile = "\\Computer3\c\Folder\FileName.xls"
strAppName = "Excel.exe " & strFileName
    Call Shell(stAppName, 1)
This above code work fine.

However, I am having a problem when the file exits on a Network computer in the “My Documents” folder. I get the following error:

“\\Computer3\c\My.xls could not be found. Check if the spelling of the file name, and verify that the file location is correct.

If you are trying to open the file from your list of most recently used files on the File menu, make sure that the file has not been renamed, moved, or deleted.”

It appears that the Shell function is trying to locate two files because of the space between the word “My” and the word “Documents” (My Documents). As long as the target file path contains no spaces the Shell functions work perfectly.

My question is: How can you open an EXCEL file when the path contains a folder that has a multiple word name.
EX: strFileName = "\\Computer3\c\My Documents\ABConsolidate.xls"

Reply With Quote
  #2 (permalink)  
Old April 13th, 2005, 07:14 AM
Friend of Wrox
Join Date: Nov 2004
Location: Seattle, WA, .
Posts: 248
Thanks: 0
Thanked 1 Time in 1 Post

When you set strAppName you have to make sure to surround text that has spaces with quotes...

strAppName = "Excel.exe " & """" & strFileName & """"

Whenever you get an error and for the sake of validation, you can make sure the path specification is correct. To do so, go to the Start menu and select "Run...". Enter the path specification that you are using. Put quotes on both ends of the file name. If the file opens, at least you know the path specification is correct.

Randall J Weers
Membership Vice President
Pacific NorthWest Access Developers Group
Reply With Quote

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
Shell seananderson Beginning VB 6 3 March 16th, 2007 05:41 AM
how to put result of shell function into variable method Beginning VB 6 1 April 20th, 2006 11:42 AM
Use of VB.NET's Shell function in C# jude_wong C# 8 December 16th, 2005 07:49 PM
shell function problem bml Excel VBA 1 February 12th, 2005 05:42 PM
Shell Function Question SerranoG Access VBA 4 November 12th, 2003 07:57 PM

All times are GMT -4. The time now is 01:52 PM.

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