Problems with headers and footers - lengthy I'm sorry

D

Debra Farnham

Win 2K
Word 2K

Hi All

Thank you to anyone in advance who has the patience to read this. I have
tried everything and read tons in these groups to try and resolve the
problems, but I'm not sure there is a bullet proof way of doing what I need.

Here's the situation (I'll try to be brief but in fear that brief may not be
descriptive enough ....... here goes.... )

When a user presses Alt + S, an inputbox appears, the user is prompted for
the name of a witness, and the witness name is then inserted into the
document with a colon, two spaces and the word SWORN following their name.
Additionally, I bookmark the name for use in a table later on.

code snippet for Alt + S (NASTY but it works for now until I clean it up
hopefully with ranges)

**************************************************
Dim strSwornName As String

strSwornName = InputBox("Enter Name of individual being sworn")

'Inserts name of witness being sworn
With Selection
.TypeText Text:=StrConv(strSwornName, vbUpperCase) & ": " & "SWORN"
.ParagraphFormat.Space15
.EndKey unit:=wdLine
.HomeKey unit:=wdLine, Extend:=wdExtend
.Font.UnderLine = wdUnderlineSingle
.MoveLeft unit:=wdCharacter, Count:=1
.MoveRight unit:=wdWord, Count:=1
.MoveRight unit:=wdWord, Count:=1, Extend:=wdExtend
End With

strWitnessName = Left(strSwornName, 1) & ". "
strWitnessName = strWitnessName & Trim(Mid(strSwornName,
InStrRev(strSwornName, " ")))


'Marks Last Name as bookmark for header
strWitnessLastName = StrConv(Selection.Range, vbProperCase)
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, name:=strWitnessLastName
End With

'Marks Last Name as bookmark for table of contents

strFWitnessName = Mid(strSwornName, InStrRev(strSwornName, " ")) &
", " & Left(strSwornName, InStr(strSwornName, " "))

********************************************

When a user presses Alt +1 , I have the text "EXAMINATION IN CHIEF BY" + a
document property being placed at the current location in the document.

code snippet
********************************
With myRng
.Text = strChief & " "
.InsertAfter ActiveDocument.CustomDocumentProperties("PTitle") & _
ActiveDocument.CustomDocumentProperties("PLastName") & ":"
.Case = wdUpperCase
.Font.UnderLine = wdUnderlineSingle

End With
***************************************
In addition to typing the text, the current code takes the name of the last
bookmark it finds in the file (the name of a witness), moves to a specified
table( table 1), inserts the bookmarked text in the first blank row and
bookmarked text page number in a specific column which is determined by the
type of examination. (Alt + 2 enters the text "CROSS-EXAMINATION BY" ...
(thus specifying a different column). That part works just fine. (Not very
elegant, but here's the gist of it - there's more but I thought this would
be enough. This piece only takes care of the Examination in Chief)
************************************************
otable.Range.Rows(otable.Rows.Count).Range.Select
With Selection
.InsertRowsBelow 1
.Collapse (wdCollapseStart)
End With
myrow = Selection.Information(wdStartOfRangeRowNumber)

With Selection
.TypeText Text:=StrConv(Trim(strFWitnessName),
vbProperCase)
.MoveLeft unit:=wdWord, Count:=3, Extend:=wdExtend
.Font.UnderLine = wdUnderlineNone
.MoveRight unit:=wdCell
Selection.InsertCrossReference
ReferenceType:="Bookmark", ReferenceKind:= _
wdPageNumber, ReferenceItem:=strBN,
InsertAsHyperlink:=False, _
IncludePosition:=False

End With

*******************************************************

I also need the header on the page where EXAMINATION IN CHIEF or
CROSS-EXAMINATION BY appears to print in the header .. however in a
different format. If ALT + 1 is pressed and EXAMINATION IN CHIEF BY appears
in the body, then the header must read "FirstInitial LastName of Witness -
in Ch." minus the quotation marks. If ALT + 2 is pressed and
CROSS-EXAMINATION BY appears in the body, then the header must read
"FirstInitial LastName of Witness - Cr. Ex.".

I have created subroutines to assemble the names properly for insertion in
the header as they are actually coming from custom document properties not
formatted the way they need to appear in the header.

The difficulty I AM having is twofold:

Problem #1

The header on all pages from section 3 to the end of the document must
ALWAYS include at least the following:

1.
R. v Name of Defendant


in addition to what I have described above (the in-Ch. or cr-Ex).on the
third line

The number 1 is the page number and a period
The R. v Name of Defendant is a field in the header that looks like this:
{ DOCPROPERTY "Header1" \* MERGEFORMAT }

Problem #2

Although the text EXAMINATION IN CHIEF BY .... may appear on page 3, that
individual's testimony may well carry over several pages until he/she is
finally CROSS-EXAMINED. At the page where the text CROSS-EXAMINATION BY
appears, the header will once again change to reflect the fact that the
cross-examination has now begun on that page. The page number and R. v Name
of Defendant must remain in the header and if the examination in chief
appears on the same page, that text must also remain in the header. I will
then need "FirstInitial LastName of Witness - cr-Ex." to appear on a fourth
line in the header.

Once a new witness is sworn in, the process begins again. That is, the
EXAMINATION IN CHIEF will have to be re-set in the header until the witness
is cross-examined etc. etc.

The document will continue to proceed in the same manner as potentially
hundreds (although that's probably excessive) of witnesses could testify.

Thank you to anyone brave enough to have read all this and further, have any
suggestions or recommendations.

Please let me know if I can clarify anything or whether I could have somehow
posted this in an easier to read format.

Legal jargon mixed with vba???? .... am I NUTS?


Debra
 
H

Helmut Weber

Hi Debra,
before the real problems can be tackled,
I'd say, you have to tidy up your code a bit.

At least for me, it is very hard to read.
And a matter of style, too.
I like short names, short code lines,
if it's just a rather short macro.
Others may have a different opinion.
Of course, this way of coding won't work
in bigger projects.

Just for the first piece of your code,
I'd start like this:

Sub Test099()
Dim sLong As String ' long name - Debra Farnham
Dim sShrt As String ' short name - D. Farnham
Dim sLast As String ' last Name - Farnham
Dim sFrst As String ' first Name abbreviated - D.
Dim lPost As Long ' Position of space
Dim lName As Long ' length of long name

sLong = "Debra Farnham" ' for testing
' sLong = "Dwight D. Eisenhower" ' for testing ???
' sLong = "John O'Casey" ' for testing

sFrst = Left(sLong, 1) & "."
lName = Len(sLong)
lPost = InStr(sLong, " ")
sLast = Right(sLong, lName - lPost)
sShrt = sFrst & " " & sLast
With Selection
.Font.Underline = wdUnderlineSingle
.Text = UCase(sLong) & ": SWORN"
.ParagraphFormat.Space15
End With

MsgBox sShrt
End Sub

Once you've got each part of the name in a variable,
things might get a lot easier and clearer.

And you see, so far, there is no moving of the selection at all.
But what are you going do to with names like "Dwight D. Eisenhower".
Some human interaction might be unavoidable.

Next step?

Greetings from Bavaria, Germany

Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
 
D

Debra Farnham

Thank you kindly for your advice Helmut.

I am taking your advice and cleaning things up.

Debra
 
M

Maura Reilly

Hi, I am going out on a limb and thinking you are a court reporter, as am I.

I have been trying to figure out how to link my headers to my in-chief, and
cross-exam, etc. but am completely useless whenit comes to this.

Is this what you are trying to do?
 
D

Debra Farnham

Hi Maura

I am not a court reporter but I am assisting some court reporters. (I was,
however a legal assistant for 20 years prior to becoming a self-taught
"computer geek". I struggle tons but I NEVER quit!

I am in fact trying to link the in-chiefs, etc. to the headers and it is
proving to be very time consuming. There are just too darn many variables.

I will not quit until I get it to work though as I know I am very close to
resolving it.


Debra
 

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