Consulting

Results 1 to 8 of 8

Thread: Solved: 462 The remote server machine does not exist or is unavailable

  1. #1
    Banned VBAX Newbie
    Joined
    Feb 2005
    Posts
    3
    Location

    Question Solved: 462 The remote server machine does not exist or is unavailable

    I am running this code in Access and I get Error 462 when I run the code more then once.

    I only get the error when I add fields to the word document.

    Adding properties does not cause any errors.

    It only happens on the second or subsequent times

    Quitting Access releases whatever does not get released in code.

    I use Office 2000 pro and XP SP2

    Please help.

    Mario

    [vba]Public Sub CreateTemplate()
    On Error GoTo HandleError

    Dim oWord As Word.Application
    Dim oDocs As Word.Documents
    Dim oFields As Word.Fields
    Dim oPrps As Object

    Dim strWordTemplate As String
    Dim strTemplatePath As String

    Set oWord = GetObject(, "Word.Application")

    strTemplatePath = oWord.Options.DefaultFilePath(wdUserTemplatesPath) & "\"
    strWordTemplate = strTemplatePath & "\Normal.dot"

    Set oDocs = oWord.Documents
    oDocs.add Template:=strWordTemplate, _
    NewTemplate:=True, _
    DocumentType:=0

    Set oPrps = oWord.ActiveDocument.CustomDocumentProperties
    oPrps.add Name:="fldTest", _
    LinkToContent:=False, _
    type:=msoPropertyTypeString, _
    value:="valTest"

    Set oFields = oWord.ActiveDocument.Fields
    'This causes the error: 462 The remote server machine does not exist or is unavailable
    'Quitting Access solves the problem
    'Something is not released. What?
    oFields.add Range:=Selection.Range, _
    type:=wdFieldEmpty, text:= _
    "DOCPROPERTY ""fldTest"" ", _
    PreserveFormatting:=True

    With oWord
    .ActiveDocument.SaveAs filename:="Test.dot", _
    FileFormat:=wdFormatTemplate, _
    LockComments:=False, _
    Password:="", _
    AddToRecentFiles:=True, _
    WritePassword:="", _
    ReadOnlyRecommended:=False, _
    EmbedTrueTypeFonts:=False, _
    SaveNativePictureFormat:=False, _
    SaveFormsData:=False, _
    SaveAsAOCELetter:=False
    End With

    ExitHere:
    Set oFields = Nothing
    Set oPrps = Nothing
    Set oDocs = Nothing
    oWord.Quit
    Set oWord = Nothing
    Exit Sub

    HandleError:
    If Err.Number = 429 Then
    Set oWord = CreateObject("Word.Application")
    Resume Next
    Else
    MsgBox Err.Number & " " & Error(Err.Number)
    Resume ExitHere:
    End If

    End Sub[/vba]

  2. #2
    Site Admin
    The Princess
    VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location
    Hi, Mario. I put VBA tags on your code. Check out my signature to learn how. Good luck!
    ~Anne Troy

  3. #3
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    Hi Mario,

    I would guess your problem is to do with:

    [VBA]Set oWord = GetObject(, "Word.Application")[/VBA]

    This is trying to get a currently existing object - in other words, an instance of Word which is already running.

    At the end of your code you do:

    [VBA]oWord.Quit
    Set oWord = Nothing[/VBA]

    This quits Word and releases the object. Next time you try and do the GetObject, it's no longer there to Get.
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  4. #4
    Banned VBAX Newbie
    Joined
    Feb 2005
    Posts
    3
    Location
    I am doing that in my exit statement:

    [VBA]
    ExitHere:
    Set oFields = Nothing
    Set oPrps = Nothing
    Set oDocs = Nothing
    oWord.Quit
    Set oWord = Nothing
    [/VBA]
    Mario

  5. #5
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    Sorry, didn't read enough before I opened my mouth and put my foot in it
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  6. #6
    Site Admin
    The Princess VBAX Guru Anne Troy's Avatar
    Joined
    May 2004
    Location
    Arlington Heights, IL
    Posts
    2,530
    Location
    Inserting footers again, Tony? ROFLMFAO!!!
    ~Anne Troy

  7. #7
    Banned VBAX Newbie
    Joined
    Feb 2005
    Posts
    3
    Location
    Well I solved the problem by changing:

    [VBA]
    oFields.add Range:=Selection.Range, _
    type:=wdFieldEmpty, text:= _
    "DOCPROPERTY ""fldTest"" ", _
    PreserveFormatting:=True
    [/VBA]
    to:
    [VBA]
    oFields.add Range:=oWord.Selection.Range, _
    type:=wdFieldEmpty, text:= _
    "DOCPROPERTY ""fldTest"" ", _
    PreserveFormatting:=True
    [/VBA]

    see also:
    http://support.microsoft.com/default...b;en-us;189618

  8. #8
    sorry guys i have the same problem but the difference is :

    i have a webbrowser and when i navigate i click a word document link, open a word document inside a webbrowser.

    set mdoc=webbrowser.document


    selection.goto what:=wdgotopage, which=wdgotoabsolute,count:=5

    and sometimes this code generate error

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •