|
-
Sep 27th, 2002, 10:08 AM
#1
Thread Starter
Lively Member
Shelling Word Documents
I'm trying to shell a word document from Access VBA, passing the path to the document in the command line. My problem is that some of the paths that are passed have spaces in them, and when you use command line parameters in this way it interprets a space as the end of the command line and thus fails to open the document. I've tried writing code to URLEncode it myself, but it doesn't like this. I've tried shelling Internet Explorer with the path in the command line, but this gives me file not found. Does anyone know of any other ways that I can open a document programmatically from Access VBA?
-
Sep 27th, 2002, 10:13 AM
#2
Frenzied Member
Just put double quotes around it
Shell "winword.exe "+chr(34)+"this is a document.doc"+chr(34)
The chr(34) puts a double quote " around the name of the document.
'Buzby'
Visual Basic Developer
"I'm moving to Theory. Everything works there."
-
Sep 27th, 2002, 11:09 AM
#3
Need-a-life Member
Try this:
VB Code:
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
Private Const SW_SHOWNORMAL = 1
'To open the file...
ShellExecute 0&, vbNullString, "C:\myDoc.doc", _
vbNullString, "C:\", SW_SHOWNORMAL
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|