![]() |
|
#10
|
||||
|
||||
|
Try:
Code:
Sub CheckDocuments()
Application.ScreenUpdating = False
Dim strFolder As String, strFile As String, strDocNm As String, wdDoc As Document, i As Long, StrTxt As String
strDocNm = ActiveDocument.FullName
strFolder = GetFolder
If strFolder = "" Then Exit Sub
strFile = Dir(strFolder & "\*.doc", vbNormal)
While strFile <> ""
If strFolder & "\" & strFile <> strDocNm Then
i = 0: StrTxt = ""
Set wdDoc = Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False)
With wdDoc
With .Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = True
.Font.ColorIndex = wdBlue
.Execute
End With
Do While .Find.Found
If .Fields.Count = 0 Then
i = i + 1: StrTxt = StrTxt & vbCr & .Text
End If
If .Information(wdWithInTable) = True Then
If .End = .Cells(1).Range.End - 1 Then
.End = .Cells(1).Range.End
.Collapse wdCollapseEnd
If .Information(wdAtEndOfRowMarker) = True Then
.End = .End + 1
End If
End If
End If
If .End = ActiveDocument.Range.End Then Exit Do
.Collapse wdCollapseEnd
.Find.Execute
Loop
End With
If i > 0 Then MsgBox i & " instance(s) found in " & .Name & ":" & StrTxt
.Close False
End With
End If
strFile = Dir()
Wend
Set wdDoc = Nothing
Application.ScreenUpdating = True
End Sub
Function GetFolder() As String
Dim oFolder As Object
GetFolder = ""
Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0)
If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path
Set oFolder = Nothing
End Function
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
| Tags |
| cross-reference, vba |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Find instances of heading text in the body of my doc, make cross reference to the actual heading
|
MAHE | Word VBA | 4 | 03-03-2018 07:59 AM |
Find {text} and insert cross reference from bookmark
|
Slamzor | Word VBA | 1 | 12-01-2017 05:12 PM |
Cross reference with pages in word ?
|
nospamdav999 | Word | 5 | 05-13-2017 03:43 AM |
Reference number and cross reference for equation numbers to match the thesis format
|
wmac | Word | 1 | 05-14-2013 08:54 PM |
| Cross reference issues with word to PDF | rammrunal | Word | 0 | 07-17-2012 05:30 AM |