Wrox Programmer Forums
|
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 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 April 12th, 2005, 09:41 AM
Registered User
 
Join Date: Apr 2005
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"

Richard
 
Old April 13th, 2005, 07:14 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 248
Thanks: 0
Thanked 1 Time in 1 Post
Default

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
http://www.pnwadg.org





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





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