I have a database with word docs. The filenames are like 000001, 000002......
I have successfully written a macro that opens these documents, makes a selection until a value is found, print this selection and then close the document again and move on to the next. (see code below )
There is one thing I want to do extra, but I can't figure it out. I want the word "End" printed under this selection (on the same page). But I want to do this without making any change in the documents.
I don't want to change the documents because the value that needs to be printed with the selection comes from an userform textbox and is different every time. But if someone can help me, you can give an example with the word end
Added a picture above off what im looking for
this is my code now:
Dim i As Long, wdApp As Object, wdDoc As Object, wdRng As Object
Set wdApp = CreateObject("Word.Application")
With wdApp
.Visible = True
For i = 1 To 9
Set wdDoc = .Documents.Open("\\path\" & Format(i, "000000") & ".NET", False, True, False)
With wdDoc
Set wdRng = .Range(0, 0)
With .Range
With .Find
.Text = "ENDLIST"
.Forward = True
.MatchWholeWord = True
.MatchCase = True
.Execute
End With
If .Find.found = True Then
wdRng.End = .Duplicate.Start
wdRng.Select
wdDoc.PrintOut , Range:=1
End If
End With
.Close False
End With
Next
.Quit
End With
Set wdRng = Nothing: Set wdDoc = Nothing: Set wdApp = Nothing
End Sub
Is this possible, and if it is can someone please help me going