Microsoft Office Forums

Go Back   Microsoft Office Forums > Microsoft Excel > Excel Programming

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 04-13-2019, 04:47 AM
scienceguy scienceguy is offline Windows 10 Office 2016
Novice
 
Join Date: Feb 2019
Posts: 17
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
  #2  
Old 04-13-2019, 06:16 AM
Pecoflyer's Avatar
Pecoflyer Pecoflyer is offline Windows 7 64bit Office 2010 64bit
Moderator
 
Join Date: Nov 2011
Location: Brussels Belgium
Posts: 2,367
Pecoflyer is a glorious beacon of lightPecoflyer is a glorious beacon of lightPecoflyer is a glorious beacon of lightPecoflyer is a glorious beacon of lightPecoflyer is a glorious beacon of light
Default

In the future please post in the correct forum.
I moved it for you
__________________
Problem solved ? Let others know by clicking " Thread Tools" then " Mark thread as solved".( This can be undone if need be)
Want to thank for the help received ? Click the scales symbol in the upper right corner of a post from the person you want to thank.
Reply With Quote
  #3  
Old 04-15-2019, 02:57 AM
Debaser's Avatar
Debaser Debaser is offline Windows 7 64bit Office 2010 32bit
Competent Performer
 
Join Date: Oct 2015
Posts: 164
Debaser is on a distinguished road
Default

You didn't properly qualify your Documents.Open call. It should read:

Code:
    Set wdDoc = wdApp.Documents.Open(Filename:=strFolder & "\" & strfile, AddToRecentFiles:=False, Visible:=False)
Reply With Quote
  #4  
Old 04-15-2019, 05:26 PM
scienceguy scienceguy is offline Windows 10 Office 2016
Novice
 
Join Date: Feb 2019
Posts: 17
scienceguy is on a distinguished road
Default

Thank you!
Reply With Quote
Reply

Tags
error 462, excel 2016

Thread Tools
Display Modes


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
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


All times are GMT -7. The time now is 09:44 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
MSOfficeForums.com is not affiliated with Microsoft