Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 04-13-2019, 04:47 AM
scienceguy scienceguy is offline Run-time error '462': The remote server machine does not exist or is unavailable Windows 10 Run-time error '462': The remote server machine does not exist or is unavailable Office 2016
Advanced Beginner
Run-time error '462': The remote server machine does not exist or is unavailable
 
Join Date: Feb 2019
Posts: 46
scienceguy is on a distinguished road
Default Run-time error '462': The remote server machine does not exist or is unavailable

Hello,

I have the following code, which looks for certain text within MS Word and adds the text to an MS Excel spreadsheet. However, every other time I run it, I get the error message, "Run-time error '462': The remote server machine does not exist or is unavailable." The first time it runs, it works, but the second time I run it, I get the error. After reviewing this error on the web, I'm baffled what I'm doing wrong. Can someone help me, please?



Many thanks,
Roy

Code:
Sub findExternalLinks()
'
'
Dim wdApp As Object
Dim wdDoc As Object
Dim aRng As Object
Dim sResponse As String
Dim xlRow As Integer
Dim xlCol As Integer
Dim strFolder As String
Dim StartTime As Date
Dim EndTime As Date
Dim strOutput As String
Dim fileCounter As Integer
Dim Interval As Date
Dim totalFiles As Integer
Dim PctDone As Single

With Application.FileDialog(msoFileDialogFolderPicker)
    If .Show = -1 Then
        strFolder = .SelectedItems(1)
    End If
End With
If strFolder = "" Then
    Exit Sub
End If

Application.ScreenUpdating = False

ThisWorkbook.Sheets("Log").Visible = True

StartTime = Now()

UserForm1.Show False
UpdateProgressBar 0

totalFiles = countFiles(strFolder)
xlRow = 1

Set wdApp = CreateObject("Word.Application")
wdApp.Visible = False

strfile = Dir(strFolder & "\*.doc", vbNormal)

While strfile <> ""
    Set wdDoc = Documents.Open(Filename:=strFolder & "\" & strfile, AddToRecentFiles:=False, Visible:=False)
    fileCounter = fileCounter + 1
    xlCol = 1
    ThisWorkbook.Sheets("Log").Cells(xlRow, xlCol).Value = wdDoc.Name
    
       
    sResponse = "<[32].[231].[PSAR].[.0-9]{1,}" 'Module prefixes 3.2, 2.3, 2.1
    Set aRng = wdDoc.Range
    
    With aRng.Find
        .ClearFormatting
        .Text = sResponse
        .MatchWildcards = True
        Do While .Execute  ' Loop until Word can no longer find the search string
            xlCol = xlCol + 1
            ThisWorkbook.Sheets("ExtLinksLog").Cells(xlRow, xlCol).Value = aRng.Text
        Loop
    End With
    
    ' Update the percentage completed.
    PctDone = fileCounter / totalFiles

    ' Call subroutine that updates the progress bar.
    UpdateProgressBar PctDone
    
    wdDoc.Close False
    xlRow = xlRow + 1
    strfile = Dir()
Wend

Set aRng = Nothing
Set wdDoc = Nothing
wdApp.Quit
Set wdApp = Nothing

Application.ScreenUpdating = True

EndTime = Now()
Interval = EndTime - StartTime

strOutput = Int(CSng(Interval * 24 * 60)) & ":" & Format(Interval, "ss")

ThisWorkbook.Sheets("Log").Cells(xlRow, 1).Value = "This code processed " & fileCounter & " files in " & strOutput

ThisWorkbook.Sheets("Main").Activate

ActiveWorkbook.Save

UserForm1.cmdUnload.Enabled = True
UserForm1.Label1.Caption = "Done!"
UserForm1.LabelFinal.Caption = "This code processed " & fileCounter & " files in " & strOutput

Sub UpdateProgressBar(PctDone As Single)
    With UserForm1

        ' Update the Caption property of the Frame control.
        .FrameProgress.Caption = Format(PctDone, "0%")

        ' Widen the Label control.
        .LabelProgress.Width = PctDone * _
            (.FrameProgress.Width - 19)
    End With

    ' The DoEvents allows the UserForm to update.
    DoEvents
End Sub
Reply With Quote
 

Tags
error 462, excel 2016



Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple Timesheets - id'ing two people working on the same machine at the same time. Will Excel 1 09-28-2016 09:12 AM
Error 6124 on User (NOT DEVELOPER) Machine EnigmaMatter Word VBA 2 09-11-2014 05:15 PM
My battle with exchange server remote access! bhroom Outlook 2 05-21-2011 09:43 AM
Run-time error '462': The remote server machine does not exist or is unavailable SMTP error from remote server in greeting rolly Outlook 1 01-19-2011 07:22 PM
unable to open .RTF files in server machine from client machine Naresh_1210 Word 0 03-12-2010 03:26 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:31 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft