PDA

View Full Version : 2 part question about creating footnotes in a template



chukesgirl2
04-06-2011, 01:22 PM
Greetings
I posted this question on Tek Tips about a week ago and haven't gotten any response, so I'm hoping for something here.

I have a pretty simple template with a custom userform. I put a listbox in the userform from which the users can select 1 to 3 of the 4 names listed. The Listbox names go into a footnote that is always in the document and it should have an asterisk instead of a number in tthe body of the document as well as before the footnote text. How do I create this particular footnote?

Secondly, after the template has run, the user freeform types the remainder of the document. They always use footnotes, so is it possible to have their first footnote start with the number 1?

The final output of this template should look like the sample below. Thanks for any and all help.

Bookmarked Name ...........)
....................................)
Bookmarked Member #..... ) .....Bookmarked Case #
....................................)
Bookmarked Member Type .)
_______________________)

BY THE COURT:*(Bookmarked Listbox)

The user starts freeform typing and let's say they want to put in a footnote at this point 1/. How can i get the number to start at 1?



__________________
*Before ListBox Name1, Listbox Name 2 and Listbox Name 3

1/ This is the users footnote 1 text

macropod
04-06-2011, 07:33 PM
hi chukesgirl,

You could use code like:
Sub AddFootnote(StrTxt As String)
Dim BmkNm As String, BmkRng As Range
BmkNm = "BkMk"
With ActiveDocument.Sections(1).Range
With .FootnoteOptions
.Location = wdBottomOfPage
.NumberingRule = wdRestartContinuous
.StartingNumber = 1
.NumberStyle = wdNoteNumberStyleArabic
End With
Set BmkRng = .Bookmarks(BmkNm).Range
BmkRng.Text = vbNullString
.Footnotes.Add Range:=BmkRng, Reference:="*", Text:=StrTxt
BmkRng.End = BmkRng.End + 1
.Bookmarks.Add BmkNm, BmkRng
Set BmkRng = Nothing
End With
End Sub
Where your userform calls the sub with:
AddFootnote TextBox#.Text
and TextBox# is the name and number of the TextBox with the footnote text.