A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Can't shell out to open a document listed on a form - has comma in name



 
 
Thread Tools Display Modes
  #1  
Old June 18th, 2008, 05:59 PM posted to microsoft.public.access.forms
M Skabialka
external usenet poster
 
Posts: 570
Default Can't shell out to open a document listed on a form - has comma in name

I have an Access 2003 form that lists documents and their path using a
listbox. Users can select these and double-click to open them.
Except that I found some documents with commas in their name. The command I
use is:
Call Shell("Explorer.exe " & txtFilePath, vbNormalFocus) which contains info
like this:
Call Shell("Explorer.exe G:\Resumes\Smith, Jones 12/12/07", vbNormalFocus)
which gives an error, and seems to select the text after the comma for this
message:
The path 'Jones 12/12/07' does not exist or is not a directory
The file does not open.

If I put
G:\Resumes\Smith, Jones 12/12/07
in an Explorer Window it opens the document, so I don't think Windows XP is
the problem.

How can I resolve this in trying to open these docs from Access (there are
too many with commas to ignore or rename).
Thanks,
Mich


  #2  
Old June 18th, 2008, 07:45 PM posted to microsoft.public.access.forms
Klatuu
external usenet poster
 
Posts: 7,074
Default Can't shell out to open a document listed on a form - has comma in

It is not just the commas, it will fail with just spaces in the name. The
cure it to enclose the passed value in quotes:
Call Shell("Explorer.exe """ & txtfilepath & """", vbNormalFocus)
--
Dave Hargis, Microsoft Access MVP


"M Skabialka" wrote:

I have an Access 2003 form that lists documents and their path using a
listbox. Users can select these and double-click to open them.
Except that I found some documents with commas in their name. The command I
use is:
Call Shell("Explorer.exe " & txtFilePath, vbNormalFocus) which contains info
like this:
Call Shell("Explorer.exe G:\Resumes\Smith, Jones 12/12/07", vbNormalFocus)
which gives an error, and seems to select the text after the comma for this
message:
The path 'Jones 12/12/07' does not exist or is not a directory
The file does not open.

If I put
G:\Resumes\Smith, Jones 12/12/07
in an Explorer Window it opens the document, so I don't think Windows XP is
the problem.

How can I resolve this in trying to open these docs from Access (there are
too many with commas to ignore or rename).
Thanks,
Mich



  #3  
Old June 18th, 2008, 08:09 PM posted to microsoft.public.access.forms
M Skabialka
external usenet poster
 
Posts: 570
Default Can't shell out to open a document listed on a form - has comma in

I finally got it working by adding Chr(34) at each end of the string -
spaces were no problem.
Call Shell("Explorer.exe " & Chr(34) & txtfilepath & Chr(34), vbNormalFocus)
Thanks anyway!
Mich

"Klatuu" wrote in message
...
It is not just the commas, it will fail with just spaces in the name. The
cure it to enclose the passed value in quotes:
Call Shell("Explorer.exe """ & txtfilepath & """", vbNormalFocus)
--
Dave Hargis, Microsoft Access MVP


"M Skabialka" wrote:

I have an Access 2003 form that lists documents and their path using a
listbox. Users can select these and double-click to open them.
Except that I found some documents with commas in their name. The
command I
use is:
Call Shell("Explorer.exe " & txtFilePath, vbNormalFocus) which contains
info
like this:
Call Shell("Explorer.exe G:\Resumes\Smith, Jones 12/12/07",
vbNormalFocus)
which gives an error, and seems to select the text after the comma for
this
message:
The path 'Jones 12/12/07' does not exist or is not a directory
The file does not open.

If I put
G:\Resumes\Smith, Jones 12/12/07
in an Explorer Window it opens the document, so I don't think Windows XP
is
the problem.

How can I resolve this in trying to open these docs from Access (there
are
too many with commas to ignore or rename).
Thanks,
Mich





  #4  
Old June 18th, 2008, 08:18 PM posted to microsoft.public.access.forms
Klatuu
external usenet poster
 
Posts: 7,074
Default Can't shell out to open a document listed on a form - has comm

I tested the code I sent. It does exactly what you are doing with the Chr(34)

--
Dave Hargis, Microsoft Access MVP


"M Skabialka" wrote:

I finally got it working by adding Chr(34) at each end of the string -
spaces were no problem.
Call Shell("Explorer.exe " & Chr(34) & txtfilepath & Chr(34), vbNormalFocus)
Thanks anyway!
Mich

"Klatuu" wrote in message
...
It is not just the commas, it will fail with just spaces in the name. The
cure it to enclose the passed value in quotes:
Call Shell("Explorer.exe """ & txtfilepath & """", vbNormalFocus)
--
Dave Hargis, Microsoft Access MVP


"M Skabialka" wrote:

I have an Access 2003 form that lists documents and their path using a
listbox. Users can select these and double-click to open them.
Except that I found some documents with commas in their name. The
command I
use is:
Call Shell("Explorer.exe " & txtFilePath, vbNormalFocus) which contains
info
like this:
Call Shell("Explorer.exe G:\Resumes\Smith, Jones 12/12/07",
vbNormalFocus)
which gives an error, and seems to select the text after the comma for
this
message:
The path 'Jones 12/12/07' does not exist or is not a directory
The file does not open.

If I put
G:\Resumes\Smith, Jones 12/12/07
in an Explorer Window it opens the document, so I don't think Windows XP
is
the problem.

How can I resolve this in trying to open these docs from Access (there
are
too many with commas to ignore or rename).
Thanks,
Mich






 




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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:36 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.