S
singeredel
In the following code, bookmarked areas are filled with variable text and
then the bookmark is recreated so that bookmark reference fields can be
updated through the report using the same data.
In Select Case 6, 7 and 8 the oRng.Text includes additional data other than
just bText. For example: oRng.Text = "RE:" + Chr(9) + bText. I would like to
know how I can revert those particular bookmark ranges back to just bText
after the process has finished so that the bookmark does not include the
"RE:" + Chr(9) and can therefore be used to update bookmark reference fields
with just the bText data in other places in the document. (Hope this is clear
:O ) The existing code is as follows:
Dim bBkm As String
Dim bText As String
Dim bIndex As Long
Dim oRng As Range
For bIndex = 1 To 21
bBkm = Choose(bIndex, "ReportAddress1", "ReportAddress2",
"ReportAddress3", "ReportAddress4", _
"ReportAddress5", "PatientName", "SSN", "AttentionLine", "DOE",
"QuadisNo", "Heading", _
"DoctorName", "DoctorTitle", "ClinicAddress", "PhoneNo",
"ScheduleDate", "ClaimNumber", "DOB", _
"DOI", "EMP", "TranscriberInitials")
bText = Choose(bIndex, ReportAddress1$, ReportAddress2$,
ReportAddress3$, ReportAddress4$, _
ReportAddress5$, PatientName$, SSN$, AttentionLine$, DOE$,
QuadisNo$, ClinicName$, DoctorName$, _
DoctorTitle$, ClinicAddress$, PhoneNo$, ScheduleDate1, ClaimNumber$,
DOB$, DOI$, EMP$, TranscriberInitials$)
If ActiveDocument.Bookmarks.Exists(bBkm) = False Then
GoTo NextBkm
End If
Set oRng = ActiveDocument.Bookmarks(bBkm).Range
oRng.Text = bText
If bIndex = 6 Or bIndex = 7 Or bIndex = 8 Or bIndex = 9 Then
If ReportType$ = "SSI" Or ReportType$ = "Rehab" Or ReportType$ =
"VA" Then
oRng.Paragraphs(1).TabStops.Add _
Position:=sPs, _
Alignment:=wdAlignTabLeft
oRng.Paragraphs(1).TabStops.Add _
Position:=(sPs2), _
Alignment:=wdAlignTabRight
End If
End If
ActiveDocument.Fields.Update
Select Case bIndex
Case 1 'ReportAddress1
If ReportType$ = "EDD" Then
oRng.Font.Bold = False
End If
oRng.Font.AllCaps = True
Case 4 'ReportAddress4
If Len(bText) = 0 Then
oRng.Delete
Else: oRng.Paragraphs.Style = "Normal"
End If
Case 5 'ReportAddress5
If Len(bText) = 0 Then
oRng.Delete
Else: oRng.Paragraphs.Style = "Normal"
End If
Case 6 'PatientName
If ReportType$ = "SSI" Or ReportType$ = "Rehab" Or ReportType$ =
"VA" Then
oRng.Text = "RE:" + Chr(9) + bText
End If
If ReportType$ = "EDD" Then
oRng.Font.Bold = False
End If
oRng.Font.AllCaps = True
Case 7 'SSN
If ReportType$ = "SSI" Then
oRng.Text = "SSN:" + Chr(9) + bText
End If
Case 8 'AttentionLine
If ReportType$ = "SSI" Or ReportType$ = "Rehab" Then
oRng.Text = "ATTN:" + Chr(9) + bText
End If
oRng.Font.AllCaps = True
Case 9 'DOE
oRng.Text = "DATE OF EXAM:" + Chr(9) + bText
Case 10 'Quadis
If optQuadisYes = True Then
oRng.Text = "DocID " + bText
Else:
oRng.Select
oRng.Delete
Selection.Delete Unit:=wdCharacter, Count:=1
End If
Case 11 'ClinicName
oRng.Paragraphs.Alignment = wdAlignParagraphCenter
oRng.Font.Bold = True
oRng.Font.AllCaps = True
oRng.Font.Size = "14"
Case 12 'DoctorName
oRng.Paragraphs.Alignment = wdAlignParagraphCenter
oRng.Font.Bold = True
oRng.Font.AllCaps = True
Case 13 'DoctorTitle
oRng.Paragraphs.Alignment = wdAlignParagraphCenter
oRng.Font.Bold = True
Case 14 'ClinicAddress
oRng.Paragraphs.Alignment = wdAlignParagraphCenter
Case 15 'PhoneNo
oRng.Paragraphs.Alignment = wdAlignParagraphCenter
Case 16 'ScheduleDate'
oRng.Font.Bold = False
End Select
With oRng.Paragraphs.Style = "Default Paragraph Font"
ActiveDocument.Bookmarks.Add Name:=bBkm, Range:=oRng
End With
NextBkm:
Next
Thank you!
then the bookmark is recreated so that bookmark reference fields can be
updated through the report using the same data.
In Select Case 6, 7 and 8 the oRng.Text includes additional data other than
just bText. For example: oRng.Text = "RE:" + Chr(9) + bText. I would like to
know how I can revert those particular bookmark ranges back to just bText
after the process has finished so that the bookmark does not include the
"RE:" + Chr(9) and can therefore be used to update bookmark reference fields
with just the bText data in other places in the document. (Hope this is clear
:O ) The existing code is as follows:
Dim bBkm As String
Dim bText As String
Dim bIndex As Long
Dim oRng As Range
For bIndex = 1 To 21
bBkm = Choose(bIndex, "ReportAddress1", "ReportAddress2",
"ReportAddress3", "ReportAddress4", _
"ReportAddress5", "PatientName", "SSN", "AttentionLine", "DOE",
"QuadisNo", "Heading", _
"DoctorName", "DoctorTitle", "ClinicAddress", "PhoneNo",
"ScheduleDate", "ClaimNumber", "DOB", _
"DOI", "EMP", "TranscriberInitials")
bText = Choose(bIndex, ReportAddress1$, ReportAddress2$,
ReportAddress3$, ReportAddress4$, _
ReportAddress5$, PatientName$, SSN$, AttentionLine$, DOE$,
QuadisNo$, ClinicName$, DoctorName$, _
DoctorTitle$, ClinicAddress$, PhoneNo$, ScheduleDate1, ClaimNumber$,
DOB$, DOI$, EMP$, TranscriberInitials$)
If ActiveDocument.Bookmarks.Exists(bBkm) = False Then
GoTo NextBkm
End If
Set oRng = ActiveDocument.Bookmarks(bBkm).Range
oRng.Text = bText
If bIndex = 6 Or bIndex = 7 Or bIndex = 8 Or bIndex = 9 Then
If ReportType$ = "SSI" Or ReportType$ = "Rehab" Or ReportType$ =
"VA" Then
oRng.Paragraphs(1).TabStops.Add _
Position:=sPs, _
Alignment:=wdAlignTabLeft
oRng.Paragraphs(1).TabStops.Add _
Position:=(sPs2), _
Alignment:=wdAlignTabRight
End If
End If
ActiveDocument.Fields.Update
Select Case bIndex
Case 1 'ReportAddress1
If ReportType$ = "EDD" Then
oRng.Font.Bold = False
End If
oRng.Font.AllCaps = True
Case 4 'ReportAddress4
If Len(bText) = 0 Then
oRng.Delete
Else: oRng.Paragraphs.Style = "Normal"
End If
Case 5 'ReportAddress5
If Len(bText) = 0 Then
oRng.Delete
Else: oRng.Paragraphs.Style = "Normal"
End If
Case 6 'PatientName
If ReportType$ = "SSI" Or ReportType$ = "Rehab" Or ReportType$ =
"VA" Then
oRng.Text = "RE:" + Chr(9) + bText
End If
If ReportType$ = "EDD" Then
oRng.Font.Bold = False
End If
oRng.Font.AllCaps = True
Case 7 'SSN
If ReportType$ = "SSI" Then
oRng.Text = "SSN:" + Chr(9) + bText
End If
Case 8 'AttentionLine
If ReportType$ = "SSI" Or ReportType$ = "Rehab" Then
oRng.Text = "ATTN:" + Chr(9) + bText
End If
oRng.Font.AllCaps = True
Case 9 'DOE
oRng.Text = "DATE OF EXAM:" + Chr(9) + bText
Case 10 'Quadis
If optQuadisYes = True Then
oRng.Text = "DocID " + bText
Else:
oRng.Select
oRng.Delete
Selection.Delete Unit:=wdCharacter, Count:=1
End If
Case 11 'ClinicName
oRng.Paragraphs.Alignment = wdAlignParagraphCenter
oRng.Font.Bold = True
oRng.Font.AllCaps = True
oRng.Font.Size = "14"
Case 12 'DoctorName
oRng.Paragraphs.Alignment = wdAlignParagraphCenter
oRng.Font.Bold = True
oRng.Font.AllCaps = True
Case 13 'DoctorTitle
oRng.Paragraphs.Alignment = wdAlignParagraphCenter
oRng.Font.Bold = True
Case 14 'ClinicAddress
oRng.Paragraphs.Alignment = wdAlignParagraphCenter
Case 15 'PhoneNo
oRng.Paragraphs.Alignment = wdAlignParagraphCenter
Case 16 'ScheduleDate'
oRng.Font.Bold = False
End Select
With oRng.Paragraphs.Style = "Default Paragraph Font"
ActiveDocument.Bookmarks.Add Name:=bBkm, Range:=oRng
End With
NextBkm:
Next
Thank you!