I'm working on a forms template sort of system that allows our staff to make forms from form templates that we have.
Just quickly this is the code i use to get the word object which is on a button click.
Set WordObj = GetObject(, "Word.Application")
If Err.Number <> 0 Then
Set WordObj = CreateObject("Word.Application")
'opens template updates bookmarks
WordObj.Documents.Add Template:="\\aqms02\qa$\McTemplates\" & fileName, NewTemplate:=False
UpdateBookmark "revision", revisionNum & ""
UpdateBookmark "jobn", ProjSec & ""
UpdateBookmark "qaid", "QA" & QA_ID
UpdateBookmark "revdate", Date & ""
Sub UpdateBookmark(ByRef BookmarkToUpdate As String, ByRef TextToUse As String)
Dim BMRange As Range
Set BMRange = ActiveDocument.Bookmarks(BookmarkToUpdate).Range '<<<<errors here
BMRange.Text = TextToUse
ActiveDocument.Bookmarks.Add BookmarkToUpdate, BMRange
at that line above it errors with the following.
Run-time error '462':
The remote server machine does not exist or is unavailable
Can anyone explain what this means, as it only happens sometimes when word is already open. it works perfectly if word is not open, and I don't really want to force word to close everytime someone wants to complete a form.