Solved

Access, word automation runtime error 462?

Posted on 2004-09-26
3
241 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
Comment Utility
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
Comment Utility
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
Comment Utility
To easy mate!

Good luck with your app.

Dave
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now