+ Reply to Thread
Results 1 to 5 of 5

working with WORD via Excel VBA : Running into Error 462: The remote server machine does

  1. #1
    Registered User
    Join Date
    05-05-2010
    Location
    Bangalore
    MS-Off Ver
    Excel 2003
    Posts
    6

    working with WORD via Excel VBA : Running into Error 462: The remote server machine does

    Hello

    Thanks in advance for your kind support

    I have been working with WORD via Excel VBA (mailmerge), I have been trying to open a word file programmatically in excel vba and adding/editing contents in it using bookmarks. However, I find that on alternate runs, I get the 'Error 462: The remote server does not exist" error. I researched a lot and understood this has something to do 'Unqualified references;.

    However I don't understand how to correct the below snippet of code to qualified references? Can someone please help?

    Also is there a positbility that I can protect the generated letter with password from macro, if yes can you guide me on it.


    Option Explicit
    Sub Generate_Letter()
    Application.DisplayAlerts = False
    Dim wd As Object
    Dim wdocSource As Object
    Dim strWorkbookName As String
    Dim wdmain, wdtable As String

    Dim clausea, clauseb, clausec As String
    ActiveWorkbook.save

    If Range("PSD_PL").Value = "" Or Range("Cont_TY").Value = "" _
    Or Range("S_O_B").Value = "" Or Range("BO_PL").Value = "" Or Range("RL_PL").Value = "" _
    Or Range("OF_PL").Value = "" Or Range("NCC_PL").Value = "" Then

    MsgBox "Please fill in all the fileds", vbCritical
    Exit Sub
    End If

    On Error Resume Next
    Set wd = GetObject(, "Word.Application")
    'If wd Is Nothing Then
    If wd Is Nothing Then 'Word isn't already running
    Set wd = CreateObject("Word.Application")
    'Set wd = New Word.Application
    End If
    On Error GoTo 0
    'On Error GoTo aa

    wdmain = Range("T_Path").Value 'Actual Template Path
    wdtable = "PLC"

    Set wdocSource = wd.Documents.Open(wdmain)
    strWorkbookName = ThisWorkbook.Path & "\" & ThisWorkbook.Name
    wdocSource.MailMerge.MainDocumentType = wdFormLetters
    wdocSource.MailMerge.OpenDataSource _
    Name:=strWorkbookName, _
    AddToRecentFiles:=False, _
    Revert:=False, _
    Format:=wdOpenFormatAuto, _
    Connection:="Data Source=" & strWorkbookName & ";Mode=Read", _
    SQLStatement:="SELECT * FROM [" & wdtable & "]"

    'conditions if any--------------------


    With wdocSource.MailMerge
    .Destination = wdSendToNewDocument
    .SuppressBlankLines = True

    With .DataSource
    .FirstRecord = wdDefaultFirstRecord
    .LastRecord = wdDefaultLastRecord
    End With
    .Execute Pause:=False
    End With

    wd.Visible = True
    wdocSource.Close savechanges:=False
    Set wdocSource = Nothing
    Set wd = Nothing


    Application.DisplayAlerts = True

    MsgBox "Please Save the Word File", vbInformation + vbOKOnly
    End Sub

  2. #2
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: working with WORD via Excel VBA : Running into Error 462: The remote server machine d

    Hi,

    It appears your code is late bound but it requires several constants from the Word Object library. I suggest you add the following to the start of the code
    Please Login or Register  to view this content.
    In order to assign a password I believe you may add
    Please Login or Register  to view this content.
    after you have closed the merge source document.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  3. #3
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,596

    Re: working with WORD via Excel VBA : Running into Error 462: The remote server machine d

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

  4. #4
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: working with WORD via Excel VBA : Running into Error 462: The remote server machine d

    Also posted on Ozgrid

  5. #5
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,596

    Re: working with WORD via Excel VBA : Running into Error 462: The remote server machine d

    @gvreddyhr :
    Your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).


    @cytop :
    Thanks for notify. Since you already saw it please put also link so other members can check is it solved already

    http://www.ozgrid.com/forum/showthread.php?t=201048

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Run time error 462 the remote server machine does not exist or is unavailable
    By kenli87 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-18-2015, 04:46 AM
  2. Running Excel on a remote machine?
    By Carl22 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-07-2015, 08:15 AM
  3. Error 426 Remote server machine does not exist or is unavailable.
    By UML in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-24-2014, 07:04 PM
  4. Replies: 0
    Last Post: 04-29-2013, 05:06 PM
  5. Working code on my machine is returning out of range error on another machine.
    By je.suis.ketan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-16-2012, 11:51 PM
  6. Remote Server Machine does not exist error
    By Josh_123456 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-07-2007, 03:11 PM
  7. [SOLVED] RTD server on remote machine.
    By Mike Kamzyuk in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-11-2005, 09:06 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1