Bookmarks and reference fields again!

S

singeredel

Can anyone please help me with this code. I cannot get the text that is
placed in the reference field to take on the default font of the paragraph
where it is placed via the reference field. It keeps showing up as the font
of the bookmark text.

Dim bBkm As String
Dim bText As String
Dim bIndex As Long
Dim oRng As Range

For bIndex = 1 To 8

bBkm = Choose(bIndex, "ReportDate", "Addressee", "AttentionLine",
"ReferringPhysician", _
"PatientName", "SSN", "ReportTitle", "County")

bText = Choose(bIndex, ReportDate3, Addressee, AttentionLine,
RequestForConsultation, _
PatientName, SSN, ReportTitle, County)

If ActiveDocument.Bookmarks.Exists(bBkm) = False Then
GoTo NextBkm
End If

Set oRng = ActiveDocument.Bookmarks(bBkm).Range
oRng.Text = bText

Select Case bIndex

Case 2 'Addressee
oRng.Font.Bold = True

Case 3 'AttentionLine
If ReportType = "SSI" = True Then
oRng.Font.AllCaps = True
Else:
oRng.Font.Bold = True
End If

Case 4 'RequestForConsultation
oRng.Font.Bold = True

Case 5 'PatientName
If ReportType = "SSI" Then
oRng.Font.Bold = False
Else:
oRng.Font.AllCaps = True
oRng.Font.Bold = True
End If

Case 6 'SSN
If ReportType = "SSI" Then
oRng.Font.Bold = False
oRng.Font.AllCaps = True
ElseIf ReportType = "EDD" Or ReportType = "EDG" Then
oRng.Font.Bold = True
oRng.Font.AllCaps = True
End If
Case 7 'Report Title
oRng.Font.Bold = True
oRng.Font.AllCaps = True

End Select

ActiveDocument.Bookmarks.Add Name:=bBkm, Range:=oRng

NextBkm:
Next

ActiveDocument.Fields.Update

Dim oFld As Field

For Each oFld In ActiveDocument.Fields
oFld.Result.Style = "Default Paragraph Font"
On Error Resume Next
Next

Much Thanks...!!
 
M

macropod

Hi Julie,

Try adding a Charformat switch to each of your REF fields (eg {REF BkMrk \*
Charformat}, and making sure the first alpha-numeric character in each field
(probably the 'R' in 'REF') is formatted to match the underlying paragraph.

Cheers
 
S

singeredel

Thanks for your help. I have tried everything I know and what you suggested
as well, but my results are inconsistent. Sometimes it works, and sometimes
it uses the formatting of the bookmark for the reference field formatting. I
cannot figure out what is wrong. Is it possible that the fields have to be
visible before it will apply the formatting?
--
singeredel


macropod said:
Hi Julie,

Try adding a Charformat switch to each of your REF fields (eg {REF BkMrk \*
Charformat}, and making sure the first alpha-numeric character in each field
(probably the 'R' in 'REF') is formatted to match the underlying paragraph.

Cheers

--
macropod
[MVP - Microsoft Word]


singeredel said:
Can anyone please help me with this code. I cannot get the text that is
placed in the reference field to take on the default font of the paragraph
where it is placed via the reference field. It keeps showing up as the font
of the bookmark text.

Dim bBkm As String
Dim bText As String
Dim bIndex As Long
Dim oRng As Range

For bIndex = 1 To 8

bBkm = Choose(bIndex, "ReportDate", "Addressee", "AttentionLine",
"ReferringPhysician", _
"PatientName", "SSN", "ReportTitle", "County")

bText = Choose(bIndex, ReportDate3, Addressee, AttentionLine,
RequestForConsultation, _
PatientName, SSN, ReportTitle, County)

If ActiveDocument.Bookmarks.Exists(bBkm) = False Then
GoTo NextBkm
End If

Set oRng = ActiveDocument.Bookmarks(bBkm).Range
oRng.Text = bText

Select Case bIndex

Case 2 'Addressee
oRng.Font.Bold = True

Case 3 'AttentionLine
If ReportType = "SSI" = True Then
oRng.Font.AllCaps = True
Else:
oRng.Font.Bold = True
End If

Case 4 'RequestForConsultation
oRng.Font.Bold = True

Case 5 'PatientName
If ReportType = "SSI" Then
oRng.Font.Bold = False
Else:
oRng.Font.AllCaps = True
oRng.Font.Bold = True
End If

Case 6 'SSN
If ReportType = "SSI" Then
oRng.Font.Bold = False
oRng.Font.AllCaps = True
ElseIf ReportType = "EDD" Or ReportType = "EDG" Then
oRng.Font.Bold = True
oRng.Font.AllCaps = True
End If
Case 7 'Report Title
oRng.Font.Bold = True
oRng.Font.AllCaps = True

End Select

ActiveDocument.Bookmarks.Add Name:=bBkm, Range:=oRng

NextBkm:
Next

ActiveDocument.Fields.Update

Dim oFld As Field

For Each oFld In ActiveDocument.Fields
oFld.Result.Style = "Default Paragraph Font"
On Error Resume Next
Next

Much Thanks...!!
 
S

singeredel

Please ignore my last message. I forgot to include the "charformat" portion
of the switch. I will give this a try for a while and make sure it solved the
problem

Thanks so much!
--
singeredel


macropod said:
Hi Julie,

Try adding a Charformat switch to each of your REF fields (eg {REF BkMrk \*
Charformat}, and making sure the first alpha-numeric character in each field
(probably the 'R' in 'REF') is formatted to match the underlying paragraph.

Cheers

--
macropod
[MVP - Microsoft Word]


singeredel said:
Can anyone please help me with this code. I cannot get the text that is
placed in the reference field to take on the default font of the paragraph
where it is placed via the reference field. It keeps showing up as the font
of the bookmark text.

Dim bBkm As String
Dim bText As String
Dim bIndex As Long
Dim oRng As Range

For bIndex = 1 To 8

bBkm = Choose(bIndex, "ReportDate", "Addressee", "AttentionLine",
"ReferringPhysician", _
"PatientName", "SSN", "ReportTitle", "County")

bText = Choose(bIndex, ReportDate3, Addressee, AttentionLine,
RequestForConsultation, _
PatientName, SSN, ReportTitle, County)

If ActiveDocument.Bookmarks.Exists(bBkm) = False Then
GoTo NextBkm
End If

Set oRng = ActiveDocument.Bookmarks(bBkm).Range
oRng.Text = bText

Select Case bIndex

Case 2 'Addressee
oRng.Font.Bold = True

Case 3 'AttentionLine
If ReportType = "SSI" = True Then
oRng.Font.AllCaps = True
Else:
oRng.Font.Bold = True
End If

Case 4 'RequestForConsultation
oRng.Font.Bold = True

Case 5 'PatientName
If ReportType = "SSI" Then
oRng.Font.Bold = False
Else:
oRng.Font.AllCaps = True
oRng.Font.Bold = True
End If

Case 6 'SSN
If ReportType = "SSI" Then
oRng.Font.Bold = False
oRng.Font.AllCaps = True
ElseIf ReportType = "EDD" Or ReportType = "EDG" Then
oRng.Font.Bold = True
oRng.Font.AllCaps = True
End If
Case 7 'Report Title
oRng.Font.Bold = True
oRng.Font.AllCaps = True

End Select

ActiveDocument.Bookmarks.Add Name:=bBkm, Range:=oRng

NextBkm:
Next

ActiveDocument.Fields.Update

Dim oFld As Field

For Each oFld In ActiveDocument.Fields
oFld.Result.Style = "Default Paragraph Font"
On Error Resume Next
Next

Much Thanks...!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top