0

I have the following vba-code in an MS-Access97-frontend which opens a word-document stored on a server:

Call Shell("winword ""\\Fileserver\Contabilita\Crucial deadlines\Bonifico97.doc""", 1)

The document is a merge-document (getting data from a query and populates the document from the data retrieved)

Now, I have put the database-frontend on another computer (still using MS-Access 97 but with MS-Word 2003 installed on the PC - MS-Access 97 is still working nicely since it was installed in a different directory) but now when above code, using call shell, is being executed, I always get "Document not found". If I launch above shell command in Start/execute, the document is being opened correctly.

What could be the problem? The file-path? Did any anything change in VBA 97 and VBA2003 what regards file-paths? I am aware of the fact that there is a folder in the file-path with a space but it works nicely on the PC with office97 installed.

I would appreciate any help I can get. Thank you.

6
  • 1
    I wonder if word is in your path? I have not seen shell used with such a short reference to word. Commented Jun 15, 2011 at 19:32
  • Will a similar Shell command work with a plain (not merge) document? Commented Jun 15, 2011 at 19:44
  • I think you may need shellexecute: developerfusion.com/article/9/shell-and-shellexecute-function/2 Commented Jun 15, 2011 at 19:47
  • @Remou. It didn't like winword (which works in Access97). I resolved by using the whole path of Word 2003 i.e. "Call Shell("C:\Programmi\Microsoft Office2003\OFFICE11\WINWORD.EXE ""\\Fileserver\Contabilita\Crucial deadlines\Bonifico97.doc""", 1)" If you would put that down as an answer, I could put that as the accepted answer. Thanks. Commented Jun 15, 2011 at 20:30
  • @HansUp - no, there were no differences if the document was a merge-type or not. I already tried that. Thx anyway. Commented Jun 15, 2011 at 20:30

2 Answers 2

2

You will need to use the full path for Word.

Sign up to request clarification or add additional context in comments.

Comments

2

Alternatives to using SHELL with the full path specified for Word would be:

  1. Application.FollowHyperlink

  2. ShellExecute

In either case, you'd be opening the file with the application associated with the file association of the file you're opening. The only reason to stick with Shell() is if you're using the PID returned by the Shell() function to control the application after it's run. But your original code used Call Shell... so that wasn't an issue.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.