Solved

Access, word automation runtime error 462?

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

631 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