C
CiavProgrammer
Ok here is my problem. To sum it all up i need to , read the word document
and put a bookmark next to the word CLINIC NOTES. but the name of the
bookmark is the 3rd line below where clinic notes is on each page. How do i
read the third line on each page. Every time i do a range start and end it
reads the first page. HEre is my code: THANKS IN ADVANCE.
CODE:
Sub WordFind()
Dim rngRange As Word.Range
Dim rngRangeMethod As Word.Range
Dim rngRangeProperty As Word.Range
Dim dosearch As Find
Dim CurrPane As Pane
Dim maxpages As Integer
With ActiveDocument
'.Content.Select
'Cycle thru pages
maxpages = Selection.Information(wdNumberOfPagesInDocument)
For i = 1 To maxpages
Selection.GoTo What:=wdGoToPage, Which:=wdGoToFirst, Count:=i,
Name:=""
ActiveDocument.Bookmarks("\page").Select
If i = 1 Then
'checks for memo in the document
With Selection.Find
'finds the text memo
.Execute findtext:="Memo"
.Wrap = wdFindStop
.Forward = True
'if the word memo is found display Msg Box
If .found = True Then
MsgBox "There is a memo in this document.",
vbInformation
End If
End With
Else
'all other pages find the clinic notes and book mark them with the
patients id
'which is two lines down with a M infront of it
findclinicnote (i)
End If
Next
End With
End Sub
Sub findclinicnote(i As Integer)
Dim rngRange As Object
With Selection.Find
'finds the text memo
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext,
Count:=i, Name:=""
.Execute findtext:="CLINIC NOTE"
.Wrap = wdFindStop
.Forward = True
.MatchWildcards = True
If .found = True Then
' Selection.HomeKey Unit:=wdStory
ActiveDocument.Bookmarks.Add "P" & -i
ActiveDocument.Save
ActiveDocument.Close
End If
' MsgBox rngRange
End With
End Sub
and put a bookmark next to the word CLINIC NOTES. but the name of the
bookmark is the 3rd line below where clinic notes is on each page. How do i
read the third line on each page. Every time i do a range start and end it
reads the first page. HEre is my code: THANKS IN ADVANCE.
CODE:
Sub WordFind()
Dim rngRange As Word.Range
Dim rngRangeMethod As Word.Range
Dim rngRangeProperty As Word.Range
Dim dosearch As Find
Dim CurrPane As Pane
Dim maxpages As Integer
With ActiveDocument
'.Content.Select
'Cycle thru pages
maxpages = Selection.Information(wdNumberOfPagesInDocument)
For i = 1 To maxpages
Selection.GoTo What:=wdGoToPage, Which:=wdGoToFirst, Count:=i,
Name:=""
ActiveDocument.Bookmarks("\page").Select
If i = 1 Then
'checks for memo in the document
With Selection.Find
'finds the text memo
.Execute findtext:="Memo"
.Wrap = wdFindStop
.Forward = True
'if the word memo is found display Msg Box
If .found = True Then
MsgBox "There is a memo in this document.",
vbInformation
End If
End With
Else
'all other pages find the clinic notes and book mark them with the
patients id
'which is two lines down with a M infront of it
findclinicnote (i)
End If
Next
End With
End Sub
Sub findclinicnote(i As Integer)
Dim rngRange As Object
With Selection.Find
'finds the text memo
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext,
Count:=i, Name:=""
.Execute findtext:="CLINIC NOTE"
.Wrap = wdFindStop
.Forward = True
.MatchWildcards = True
If .found = True Then
' Selection.HomeKey Unit:=wdStory
ActiveDocument.Bookmarks.Add "P" & -i
ActiveDocument.Save
ActiveDocument.Close
End If
' MsgBox rngRange
End With
End Sub