Regarding my earlier post.

http://www.daniweb.com/forums/thread327097.html

I encounter an error saying

Run-time error '462':

The remote server machine does not exist or is unavailable

Haven't notice this error earlier.

Code:

wrdApp.Documents.Open App.Path & "\Reports\Locatorslip.docx"
wrdApp.WindowState = wdWindowStateMaximize
wrdApp.Visible = True

The code works fine. Error only appears if i click the the button again
(or other which also open a word doc.)

What would be the fix?

Thanks

Two questions,

1) Is the application running on a server?

2) Have you closed the first document when trying to open the same again?

Is the above code all the code under the command button?

1. Its only on my laptop sir, not connected to LAN or anything like that

2. Yes, i close the doc first before reopening, and by doing so, the err appears

Yes, they have the same code except the

wrdApp.Documents.Open App.Path & "\Reports\Locatorslip.docx"

I replace the doc name with another corresponding to the report named on the cmd button.

When you close the document, use -

Set wrdApp = Nothing.

To test this, open your task manager and confirm that the document or word.exe is not running under applications or under processes. This should solve your problem.:)

Great fix sir.. It's working:)

I can't open 2 Word Doc at the same time, it says something about retry or switch.

How would i go around that.

It was a pleasure.

If you want the user to continue working on other documents, you mist
religiously avoid using any of the following

Selection
ActiveDocument
ActiveWindow

To avoid using the ActiveDocument object, always open a document using
syntax like this -

Dim oDoc as Document
Set oDoc = Documents.Add(Filename:="my filename here")

That gives you a handle to the document you want to work on. Once you have
set oDoc, you can use it exactly as you would use ActiveDocument.

To avoid using the Selection object, always define a Range object from
within the specified document object. You can do almost anything with a
Range that you can do with the Selection, and you can have as many of them
as you want (whereas there is only one Selection)

To avoid using ActiveWindow, define a Window object based on oDoc in the
same way.

Do something like this -

Dim oRange as Range
Set oRange = oDoc.Range 'Range object now marks the whole of Doc2
With oRange.Find
'set up your find code here as if you used "With Selection.Find"

End With

Having defined a Range object variable, you can do almost anything with it
that you can do with the Selection. There are a few exceptions, for instance
you can't use a Range to select a column of a table. But there are
workarounds for those cases if and when you come up against them.

using ActiveWindow, define a Window object based on oDoc -

Dim oWindow As Window
Set oWindow = oDoc.Windows(1)

Then you can use oWindow in the same way that you used ActiveWindow. oWindow
will remain the window associated with oDoc even if the user changes which
document is active and therefore changes which window is the ActiveWindow.

As you can see it is quite involved. I prefer to let the user finish with one document, close it and then load another. If your user DO need to open multiple documents, play with the above code. It will be unfortunately be a learning cirve.

Should you have any more questions on these, please open a new thread. We will confuse people searching for your original question. I believe it is answered now, so please mark this as solved, thanks.:)

This question has already been answered. Start a new discussion instead.