moster67
moster67

Reputation: 850

microsoft office/access - problem with filepath using call shell from vba

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.

Upvotes: 0

Views: 2080

Answers (2)

David-W-Fenton
David-W-Fenton

Reputation: 23067

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.

Upvotes: 2

Fionnuala
Fionnuala

Reputation: 91376

You will need to use the full path for Word.

Upvotes: 2

Related Questions