Recreating Bookmark Fields

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!
 
H

Helmut Weber

Hi Julie,

I wonder, why inserting a tab first and delete it later.

Replace _one_ tab in a range with a space,
no matter wether in a bookmark or not,
like this:

Dim rtmp As Range
Set rtmp = ActiveDocument.Bookmarks("test").Range
With rtmp.Find
.Text = Chr(9)
.Replacement.Text = " "
.Execute Replace:=wdReplaceOne
End With

which may ruin a lot of formatting in your doc,
but you've asked for it.


--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
S

singeredel

[ DEPARTMENT OF SOCIAL SERVICES ] [ RE: FIRST, LAST ]
[ Disability and Adult Programs ] [ SSN: 999-99-9999 ]
[ P.O. Box 30541 ] [ ATTN: JONES ]
[ Los Angeles, CA 90030 ]


The above is the way the text appears in the document after the bookmarks
have been recreated once being filled with text.. I don't want to change the
text of what appears on the screen here. I just want to then make the
bookmarked text now only include the name, 999-99-9999, and Jones and not the
headings "RE:", "SSN", and "ATTN:" so that the patient's name, for instance,
can be inserted into a bookmark field elsewhere in the document -- I don't
want to insert into the reference fields "RE: Last, First" -- only "Last,
First"

thanks for your input.
 
M

macropod

Hi Julie,

If you're bookmarking the client's names, SSN and the attn name, you
shouldn't need to insert the data into other bookmarks elsewhere in the
document - all you need to have is a set of REF fields set up to point to
these three bookmarks. Perhaps that's what you're doing when you describe
inserting the data "into a bookmark field elsewhere in the document ", but
just in case it isn't ...

Cheers

--
macropod
[MVP - Microsoft Word]


singeredel said:
[ DEPARTMENT OF SOCIAL SERVICES ] [ RE: FIRST, LAST ]
[ Disability and Adult Programs ] [ SSN: 999-99-9999 ]
[ P.O. Box 30541 ] [ ATTN: JONES ]
[ Los Angeles, CA 90030 ]


The above is the way the text appears in the document after the bookmarks
have been recreated once being filled with text.. I don't want to change the
text of what appears on the screen here. I just want to then make the
bookmarked text now only include the name, 999-99-9999, and Jones and not the
headings "RE:", "SSN", and "ATTN:" so that the patient's name, for instance,
can be inserted into a bookmark field elsewhere in the document -- I don't
want to insert into the reference fields "RE: Last, First" -- only "Last,
First"

thanks for your input.
--
singeredel


Helmut Weber said:
Hi Julie,

I wonder, why inserting a tab first and delete it later.

Replace _one_ tab in a range with a space,
no matter wether in a bookmark or not,
like this:

Dim rtmp As Range
Set rtmp = ActiveDocument.Bookmarks("test").Range
With rtmp.Find
.Text = Chr(9)
.Replacement.Text = " "
.Execute Replace:=wdReplaceOne
End With

which may ruin a lot of formatting in your doc,
but you've asked for it.


--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
S

singeredel

I meant inserting the data into other bookmark REFERENCE fields...
--
singeredel


macropod said:
Hi Julie,

If you're bookmarking the client's names, SSN and the attn name, you
shouldn't need to insert the data into other bookmarks elsewhere in the
document - all you need to have is a set of REF fields set up to point to
these three bookmarks. Perhaps that's what you're doing when you describe
inserting the data "into a bookmark field elsewhere in the document ", but
just in case it isn't ...

Cheers

--
macropod
[MVP - Microsoft Word]


singeredel said:
[ DEPARTMENT OF SOCIAL SERVICES ] [ RE: FIRST, LAST ]
[ Disability and Adult Programs ] [ SSN: 999-99-9999 ]
[ P.O. Box 30541 ] [ ATTN: JONES ]
[ Los Angeles, CA 90030 ]


The above is the way the text appears in the document after the bookmarks
have been recreated once being filled with text.. I don't want to change the
text of what appears on the screen here. I just want to then make the
bookmarked text now only include the name, 999-99-9999, and Jones and not the
headings "RE:", "SSN", and "ATTN:" so that the patient's name, for instance,
can be inserted into a bookmark field elsewhere in the document -- I don't
want to insert into the reference fields "RE: Last, First" -- only "Last,
First"

thanks for your input.
--
singeredel


Helmut Weber said:
Hi Julie,

I wonder, why inserting a tab first and delete it later.

Replace _one_ tab in a range with a space,
no matter wether in a bookmark or not,
like this:

Dim rtmp As Range
Set rtmp = ActiveDocument.Bookmarks("test").Range
With rtmp.Find
.Text = Chr(9)
.Replacement.Text = " "
.Execute Replace:=wdReplaceOne
End With

which may ruin a lot of formatting in your doc,
but you've asked for it.


--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

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