Results 1 to 5 of 5
  1. #1
    christ2000 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2018
    Posts
    45

    Question How avoid Run Time error '462': the remote server machine does not exist or is unavailable

    Hello I am using access to fill out a word document using Bookmarks, the code work but the problem that I can use this just one time, if I run the code twice I always get this error:

    Run Time error '462': the remote server machine does not exist or is unavailable

    is there nay way to avoid this?

    this is the code I am using:

    Private Sub Command320_Click()
    Dim LWordDoc As String
    Dim oApp As Object
    'Path to the word document
    LWordDoc = "C:\Users\temp\Documents\Contractor DB\contrato.dotx"
    If Dir(LWordDoc) = "" Then
    MsgBox "Document not found."


    Else
    'Create an instance of MS Word
    Set oApp = CreateObject(Class:="Word.Application")
    oApp.Visible = True
    'Open the Document
    oApp.Documents.Open Filename:=LWordDoc
    End If

    Dim Name As Word.Range
    Set Name = ActiveDocument.Bookmarks("name").Range
    Name.Text = [Form]![Name]
    Dim LastName As Word.Range
    Set Name = ActiveDocument.Bookmarks("lastname").Range
    Name.Text = [Form]![Last Name]
    Dim Company As Word.Range
    Set Name = ActiveDocument.Bookmarks("company").Range
    Name.Text = [Form]![Company]
    Dim Address As Word.Range
    Set Name = ActiveDocument.Bookmarks("Address").Range
    Name.Text = [Form]![FullAddress]
    Dim Nombre As Word.Range
    Set Name = ActiveDocument.Bookmarks("nombre").Range
    Name.Text = [Form]![Name]
    Dim APELLIDO As Word.Range
    Set Name = ActiveDocument.Bookmarks("APELLIDO").Range
    Name.Text = [Form]![Last Name]
    Dim lastnamerate As Word.Range
    Set Name = ActiveDocument.Bookmarks("lastnamerate").Range
    Name.Text = [Form]![Last Name]
    Dim firstnamerate As Word.Range
    Set Name = ActiveDocument.Bookmarks("firstnamerate").Range
    Name.Text = [Form]![Name]
    Dim mnamerate As Word.Range
    Set Name = ActiveDocument.Bookmarks("mnamerate").Range
    Name.Text = [Form]![Middle Name]


    End Sub


    Thanks

  2. #2
    Gicu's Avatar
    Gicu is offline VIP
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,114
    What do you do with the Word document after is populated? Do you leave it open (current code) or do you want to close it? You need to cleanup your code to close/reset your variables (i.e. SetName=Nothing, Set oApp=nothing, etc.).

    Read the info in this link and it will probably get you on the right path: https://support.microsoft.com/en-ca/...-error-message

    You might want to look at replacing your existing process with mail-merge which is easier to implement and more powerful than your current approach.

    Cheers,
    Vlad

  3. #3
    christ2000 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2018
    Posts
    45
    Quote Originally Posted by Gicu View Post
    What do you do with the Word document after is populated? Do you leave it open (current code) or do you want to close it? You need to cleanup your code to close/reset your variables (i.e. SetName=Nothing, Set oApp=nothing, etc.).

    Read the info in this link and it will probably get you on the right path: https://support.microsoft.com/en-ca/...-error-message

    You might want to look at replacing your existing process with mail-merge which is easier to implement and more powerful than your current approach.

    Cheers,
    Vlad

    thanks for answer, I just print the document and close, but error always appear

  4. #4
    Gicu's Avatar
    Gicu is offline VIP
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,114
    read the info in the link; you need to close reset your variables once you are done with each instance.

    Cheers,
    Vlad

  5. #5
    christ2000 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jan 2018
    Posts
    45
    The link help to fix my error, thanks for your help GICU

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 01-11-2017, 05:10 AM
  2. Determining OS of remote machine in MS Access
    By AccessPower in forum Programming
    Replies: 4
    Last Post: 01-10-2017, 08:07 AM
  3. Run time error 2137 but record does exist
    By coach32 in forum Programming
    Replies: 5
    Last Post: 06-10-2015, 05:41 PM
  4. Replies: 3
    Last Post: 02-23-2012, 07:16 PM
  5. Getting date/time from remote server
    By mxfrail in forum Programming
    Replies: 4
    Last Post: 09-21-2009, 07:26 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums