vik1
11-08-2017, 09:05 AM
Dear Members,
In my MS-Word template, my client sends template with an error in the header section, as below,
VERMONT , ROBIN A. Date: 10/21/2017
Medical File No: 312325 DOB: 01/05/1982Claim#:
RE155B53452 DOI: 06/21/2017
The error being the ‘Claim#’ coming up right next to the DOB value, while it should come on the next line, as below:
[B]VERMONT , ROBIN A. Date: 10/02/2017
Medical File No: 312325 DOB: 01/05/1982
Claim#: RE155B53452 DOI: 06/21/2017
Also, this error comes up occasionally in some files and not all, so to solve it, I created a word macro, as below:
Sub ShiftClaimNumber2NextLine()
Dim rngStory As Word.Range
Dim lngJunk As Long
lngJunk = ActiveDocument.Sections(1).Headers(1).Range.StoryType
For Each rngStory In ActiveDocument.StoryRanges
Do
With rngStory.Find
.text = "Claim#:"
.Replacement.text = "^pClaim#:"
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
End With
Set rngStory = rngStory.NextStoryRange
Loop Until rngStory Is Nothing
Next
End Sub
And I run the above macro through a Group Macro, as below:
Sub ProcessAllDocumentsInFolder()
Dim file
Dim path As String
path = "D:\Test\"
file = Dir(path & "*.doc")
Do While file <> ""
Documents.Open FileName:=path & file
Call ShiftClaimNumber2NextLine
ActiveDocument.Save
ActiveDocument.Close
file = Dir()
Loop
End Sub
When I run the macro ProcessAllDocumentsInFolder(), for all files with such an error, it shifts the ‘Claim#’ to the next line.
However, the problem is, it also does so for files that do not have such a problem, thereby adding one enter line below the DOB, as below:
VERMONT, ROBIN S. Date: 10/21/2017
File No: 312335 DOB: 01/05/1982
Claim#: RE155B53452 DOI: 06/21/2017
What changes should I make to my macro ShiftClaimNumber2NextLine() , so that it does not make any change to files which DO NOT HAVE the ‘Claim#’ problem .
Thank you in anticipation,
In my MS-Word template, my client sends template with an error in the header section, as below,
VERMONT , ROBIN A. Date: 10/21/2017
Medical File No: 312325 DOB: 01/05/1982Claim#:
RE155B53452 DOI: 06/21/2017
The error being the ‘Claim#’ coming up right next to the DOB value, while it should come on the next line, as below:
[B]VERMONT , ROBIN A. Date: 10/02/2017
Medical File No: 312325 DOB: 01/05/1982
Claim#: RE155B53452 DOI: 06/21/2017
Also, this error comes up occasionally in some files and not all, so to solve it, I created a word macro, as below:
Sub ShiftClaimNumber2NextLine()
Dim rngStory As Word.Range
Dim lngJunk As Long
lngJunk = ActiveDocument.Sections(1).Headers(1).Range.StoryType
For Each rngStory In ActiveDocument.StoryRanges
Do
With rngStory.Find
.text = "Claim#:"
.Replacement.text = "^pClaim#:"
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
End With
Set rngStory = rngStory.NextStoryRange
Loop Until rngStory Is Nothing
Next
End Sub
And I run the above macro through a Group Macro, as below:
Sub ProcessAllDocumentsInFolder()
Dim file
Dim path As String
path = "D:\Test\"
file = Dir(path & "*.doc")
Do While file <> ""
Documents.Open FileName:=path & file
Call ShiftClaimNumber2NextLine
ActiveDocument.Save
ActiveDocument.Close
file = Dir()
Loop
End Sub
When I run the macro ProcessAllDocumentsInFolder(), for all files with such an error, it shifts the ‘Claim#’ to the next line.
However, the problem is, it also does so for files that do not have such a problem, thereby adding one enter line below the DOB, as below:
VERMONT, ROBIN S. Date: 10/21/2017
File No: 312335 DOB: 01/05/1982
Claim#: RE155B53452 DOI: 06/21/2017
What changes should I make to my macro ShiftClaimNumber2NextLine() , so that it does not make any change to files which DO NOT HAVE the ‘Claim#’ problem .
Thank you in anticipation,