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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|