Solved

Access, word automation runtime error 462?

Posted on 2004-09-26
3
243 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

930 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

12 Experts available now in Live!

Get 1:1 Help Now