Error when executing shell in access

Hello,
I have a odd problem, to which I've developed a work around.  However, I'm still curious as to why the error occurred in the first place.  I'm working on an application that is used to produce access reports and open word documents, some of which are merge documents. All the documents as well as the front-end reside on a network share.  Yes I know that each user should have their own copy of the front-end on their machine, however this is how the client wants it.

When I use the following code to open up a merged document, the word document opens up fine and the merge is executed.  However, when I try to open up a regular non-merge word document, I get an error message that the file is not found.  However, the message specifies a location on the "C:\Users\chtullu134\old.doc" has not been found.  I've stepped through the code and find that I am passing the correct code.  I'm not sure what is going on.
  Dim stAppName As String
  stAppName = "Winword.exe " & strDocPath
  Call Shell(stAppName, 1)

Open in new window


However, when using the following code to open a non-merge document, the document opens up fine.  The only problem is that while merged documents are opened up, the merge is not performed.  
'Code for non merge documente
    Dim intStrLength As Integer
    Dim strDocName As String
    Dim objWord As Object
    Set objWord = CreateObject("Word.Application")      
    Dim objPrinter As Printer
    Set objPrinter = Application.Printer
    With objWord
        .Activeprinter = objPrinter.DeviceName
        .Visible = True
        .Activate
        .Documents.Open (strDocPath)
    End With
    Set objWord = Nothing
    

Open in new window

Juan VelasquezAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hnasrCommented:
Tried the first code and it works fine after specifying the path of the document.

    Dim stAppName As String
    stAppName = "D:\s.docx"
    stAppName = "Winword.exe " & stAppName
    Call Shell(stAppName, 1)

So how to reproduce the issue?
0
Juan VelasquezAuthor Commented:
Hello Hnasr,

I and all the other users are still having the same problem opening regular word documents using
Dim stAppName As String
    stAppName = "D:\s.docx"
    stAppName = "Winword.exe " & stAppName
    Call Shell(stAppName, 1)

Open in new window


I will be posting my solution when I get to the office.
0
Juan VelasquezAuthor Commented:
I created an if statement to call either the shell command for merge documents or the following vba code if it is a non merge document
'Code for non merge documente
    Dim intStrLength As Integer
    Dim strDocName As String
    Dim objWord As Object
    Set objWord = CreateObject("Word.Application")      
    Dim objPrinter As Printer
    Set objPrinter = Application.Printer
    With objWord
        .Activeprinter = objPrinter.DeviceName
        .Visible = True
        .Activate
        .Documents.Open (strDocPath)
    End With
    Set objWord = Nothing
    
             

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Juan VelasquezAuthor Commented:
I implemented the solution I described previously
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.