Solved

Access, word automation runtime error 462?

Posted on 2004-09-26
3
245 Views
Last Modified: 2010-05-18
Hi,
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")
End If
'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 & ""
    WordObj.Activate
    DoEvents


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
End Sub

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.

0
Comment
Question by:archerdapunk
  • 2
3 Comments
 
LVL 34

Accepted Solution

by:
flavo earned 125 total points
ID: 12157547
is this code in Access??

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
End Sub

If so youll need to change Activedcoumnet to

WordObj.activedocument and pass the WordObj into the sub too
0
 

Author Comment

by:archerdapunk
ID: 12157662
Hmm well i tried that and it seems to work perfectly.. I once upon a time tried something similar but it didn't work.. It works now though.. so thanks heaps..
0
 
LVL 34

Expert Comment

by:flavo
ID: 12157667
To easy mate!

Good luck with your app.

Dave
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question