Opening Word Document from Access

  • Thread starter Thread starter Dorothy
  • Start date Start date
D

Dorothy

I am also trying to open a word document from Access, but
have had no success. I've tried what you said, but I keep
getting the message below.

"Document name or path is not valid. Try these
suggestions.
*Check the file permissions for the document or drive.
*Use the File Open dialog box to locate the document.
(M:\New)"
I know it is the correct path because I used the browse
feature. This is what the code looks like that I added
[stAppName = "c:\program files\microsoft office\office10
\WINWORD.exe M:\New File Structure\Special Projects\AYG2004
\Approval Letter.doc"]. Now I've tried this without the
C:... and just adding Winword.exe before the path and I
still get this message. Permissions also don't seem to
be a problem. Any suggestions you may have would be
greatly appreciated. Thanks
 
Dorothy,

It is not clear what you are doing here, and it looks like I missed the
first part of the conversation. But if you are using a RunApp macro, as
I presume, try the Command Line argument like this, with the application
path/name and the document path/name separately enclosed in ""s...
"C:\Program Files\Microsoft Office\Office10\WINWORD.exe" "M:\New File
Structure\Special Projects\AYG2004\Approval Letter.doc"
 
Thanks Steve, but that did not work either. It gave me a
compilation error - too many quotes. I've tried creating
a test document directly off the C drive and it works
fine, but the minute I put the document in a folder it
will not work.
-----Original Message-----
Dorothy,

It is not clear what you are doing here, and it looks like I missed the
first part of the conversation. But if you are using a RunApp macro, as
I presume, try the Command Line argument like this, with the application
path/name and the document path/name separately enclosed in ""s...
"C:\Program Files\Microsoft Office\Office10 \WINWORD.exe" "M:\New File
Structure\Special Projects\AYG2004\Approval Letter.doc"

--
Steve Schapel, Microsoft Access MVP

I am also trying to open a word document from Access, but
have had no success. I've tried what you said, but I keep
getting the message below.

"Document name or path is not valid. Try these
suggestions.
*Check the file permissions for the document or drive.
*Use the File Open dialog box to locate the document.
(M:\New)"
I know it is the correct path because I used the browse
feature. This is what the code looks like that I added
[stAppName = "c:\program files\microsoft office\office10
\WINWORD.exe M:\New File Structure\Special Projects\AYG2004
\Approval Letter.doc"]. Now I've tried this without the
C:... and just adding Winword.exe before the path and I
still get this message. Permissions also don't seem to
be a problem. Any suggestions you may have would be
greatly appreciated. Thanks
.
 
Steve, I hope you don't mind if I jump in here quick...
Dorthy,
I think Steve is on the right track. The problem is that your path to the
document has spaces in it, and because of that you will need to quote your
file and application paths.
But you can't use just regular double quotes because, as you found out, it
confuses the compiler.
This is what you are going to want:

[stAppName = Chr$(34) & "c:\program files\microsoft
office\office10\WINWORD.exe" & Chr$(34) & " " & Chr$(34) & "M:\New File
Structure\Special Projects\AYG2004\Approval Letter.doc" & Chr$(34)]

Character 34 is the double quote character in the ASCII table, so you can
embed double quotes in this way. See if this doesn't work better for you...
--
Bryan Reich
Microsoft Office
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of any included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


Dorothy said:
Thanks Steve, but that did not work either. It gave me a
compilation error - too many quotes. I've tried creating
a test document directly off the C drive and it works
fine, but the minute I put the document in a folder it
will not work.
-----Original Message-----
Dorothy,

It is not clear what you are doing here, and it looks like I missed the
first part of the conversation. But if you are using a RunApp macro, as
I presume, try the Command Line argument like this, with the application
path/name and the document path/name separately enclosed in ""s...
"C:\Program Files\Microsoft Office\Office10 \WINWORD.exe" "M:\New File
Structure\Special Projects\AYG2004\Approval Letter.doc"

--
Steve Schapel, Microsoft Access MVP

I am also trying to open a word document from Access, but
have had no success. I've tried what you said, but I keep
getting the message below.

"Document name or path is not valid. Try these
suggestions.
*Check the file permissions for the document or drive.
*Use the File Open dialog box to locate the document.
(M:\New)"
I know it is the correct path because I used the browse
feature. This is what the code looks like that I added
[stAppName = "c:\program files\microsoft office\office10
\WINWORD.exe M:\New File Structure\Special Projects\AYG2004
\Approval Letter.doc"]. Now I've tried this without the
C:... and just adding Winword.exe before the path and I
still get this message. Permissions also don't seem to
be a problem. Any suggestions you may have would be
greatly appreciated. Thanks
.
 
Compilation error? Too many quotes? This is weird. Never heard of
this before! Can you confirm that you are using a RunApp macro? Please
show precisely what you have entered for the Command Line argument. How
are you running the macro? At what point do you get the error message?
What exactly is the wording of the error message?
 
Bryan,

I guess the hurdle that you and I both face here is that we haven't got
any idea what Dorothy is doing. Since this is a macros newsgroup, one
must make the assumption her question is related to macros. So my best
guess is a RunApp macro, but Dorothy didn't respond to my question about
this... so I have asked again. If it is, there is no need for the
gymnasics of what you suggested... the syntax I suggested has worked
fine for me on hundreds of occasions, and it should work fine for
Dorothy. On the other hand, if she is doing something else, and
especially if she is trying to allocate a value to a string variable in
VBA, I agree she will need to do something like you suggested, or
perhaps more simply...
"""C:\Program Files\Microsoft Office\Office10\WINWORD.exe"" ""M:\New
File Structure\Special Projects\AYG2004\Approval Letter.doc"""
 
You're right Steve,
I pop around these different newsgroups and I wasn't paying attention to
which one I was in and her question seemed like an attempt at VBA code to
me, so I answered it in kind. My bad, I am ashamed. I should know better.
:-/
--
Bryan
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of any included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


Steve Schapel said:
Bryan,

I guess the hurdle that you and I both face here is that we haven't got
any idea what Dorothy is doing. Since this is a macros newsgroup, one
must make the assumption her question is related to macros. So my best
guess is a RunApp macro, but Dorothy didn't respond to my question about
this... so I have asked again. If it is, there is no need for the
gymnasics of what you suggested... the syntax I suggested has worked
fine for me on hundreds of occasions, and it should work fine for
Dorothy. On the other hand, if she is doing something else, and
especially if she is trying to allocate a value to a string variable in
VBA, I agree she will need to do something like you suggested, or
perhaps more simply...
"""C:\Program Files\Microsoft Office\Office10\WINWORD.exe"" ""M:\New
File Structure\Special Projects\AYG2004\Approval Letter.doc"""

--
Steve Schapel, Microsoft Access MVP
Steve, I hope you don't mind if I jump in here quick...
Dorthy,
I think Steve is on the right track. The problem is that your path to the
document has spaces in it, and because of that you will need to quote your
file and application paths.
But you can't use just regular double quotes because, as you found out, it
confuses the compiler.
This is what you are going to want:

[stAppName = Chr$(34) & "c:\program files\microsoft
office\office10\WINWORD.exe" & Chr$(34) & " " & Chr$(34) & "M:\New File
Structure\Special Projects\AYG2004\Approval Letter.doc" & Chr$(34)]

Character 34 is the double quote character in the ASCII table, so you can
embed double quotes in this way. See if this doesn't work better for you...
 
Back
Top