Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Access, word automation runtime error 462?

Posted on 2004-09-26
3
Medium Priority
?
255 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 34

Accepted Solution

by:
flavo earned 375 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

721 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