Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.pagelayout
Ruben Torrez Ruben Torrez is offline
external usenet poster
 
Posts: 1
Default Text Fields in Header/Footer that prompts for user input

I am creating a template for a document that is often created for my company.
It will be used for each section in a larger compilation. In the template
that I am creating I have added the company name to the footer which will
exist in all documents created using this template. I also want to create a
field where the user can type the name of the section for this document.
This name will only appear in the footer, no where else in the document and
will not necessarily be the filename either (I know that a FILLIN or Autotext
can automatically add the filename or section title, but these don't seem to
work for this situation). If possible I would like this to be a formatted
field (right alignment, Arial 8pt) so that the user does not have to do this
every time they use the template. Is there a way to do this?
  #2   Report Post  
Posted to microsoft.public.word.pagelayout
Lene Fredborg Lene Fredborg is offline
external usenet poster
 
Posts: 1,291
Default Text Fields in Header/Footer that prompts for user input

You could obtain what you want by following the steps below.
Result: When a user creates a new document based on your template, a prompt
will pop up, asking for the title. The entered title will automatically be
inserted in the correct position and correctly formatted in the footer no
manual adjustments are needed.

What to do:

1. In the footer of your template, type Title, format the word as you wish
the title to appear in each document (Arial 8 pt, right aligned, etc.).

2. Select the Title word. Then select Insert Bookmark. Type Title in
the Name field and click OK. Now you have bookmarked this text in the footer.

3. Add a macro named AutoNew to your template (can e.g. be added to the
ThisDocument module). The macro must prompt the user for at title and update
the Title bookmark with this title. The macro below can be used.

Sub AutoNew()
Dim strTitle As String

Retry:
strTitle = InputBox("Please enter the document title " & _
"to be inserted in the footer.", "Enter Document Title")

If StrPtr(strTitle) = 0 Then
'Cancel clicked
'INSERT WHAT NEEDS TO BE DONE - CLOSE DOCUMENT?
ElseIf Len(strTitle) = 0 Then
'No title entered, let user retry
MsgBox "You must enter a title. Please retry.", vbOKOnly, "Enter
Title"
GoTo Retry
Else
'Entry OK, update "Title" bookmark
With ActiveDocument
If .Bookmarks.Exists("Title") Then
ActiveDocument.Bookmarks("Title").Range.Text = strTitle
Else
Bookmark not found
'CHANGE THE MSG AS REQUIRED
MsgBox "The title could not be inserted." & vbCr & _
"(A bookmark named 'Title' is missing in the footer)."
End If
End With
End If

End Sub


--
Regards
Lene Fredborg
DocTools Denmark
www.thedoctools.com
Document automation add-ins, macros and templates for Microsoft Word


"Ruben Torrez" wrote:

I am creating a template for a document that is often created for my company.
It will be used for each section in a larger compilation. In the template
that I am creating I have added the company name to the footer which will
exist in all documents created using this template. I also want to create a
field where the user can type the name of the section for this document.
This name will only appear in the footer, no where else in the document and
will not necessarily be the filename either (I know that a FILLIN or Autotext
can automatically add the filename or section title, but these don't seem to
work for this situation). If possible I would like this to be a formatted
field (right alignment, Arial 8pt) so that the user does not have to do this
every time they use the template. Is there a way to do this?

  #3   Report Post  
Posted to microsoft.public.word.pagelayout
Ruben Torrez Ruben Torrez is offline
external usenet poster
 
Posts: 2
Default Text Fields in Header/Footer that prompts for user input

Thank you for the help, this sounds like it will be exactly what I need. My
only question is where do I enter this code? You say "can e.g. be added to
the
ThisDocument module" but I am not familiar with what that is. Is there an
easier way to do this or can you tell me where to find the ThisDocument
module?

Thanks again.

  #4   Report Post  
Posted to microsoft.public.word.pagelayout
Lene Fredborg Lene Fredborg is offline
external usenet poster
 
Posts: 1,291
Default Text Fields in Header/Footer that prompts for user input

Ruben,

Macros are added to templates and documents via the Visual Basic (VBA)
editor in Word (you can quickly access the editor via the shortcut Alt+F11).
In VBA, each template or document has a ThisDocument module and you can add
other modules yourself. A module can contain several macros.

For an introduction to macros and VBA, see these articles:

http://www.gmayor.com/installing_macro.htm
http://www.word.mvps.org/FAQs/Macros...eateAMacro.htm

Please post back if you need further help.
--
Regards
Lene Fredborg


"Ruben Torrez" wrote:

Thank you for the help, this sounds like it will be exactly what I need. My
only question is where do I enter this code? You say "can e.g. be added to
the
ThisDocument module" but I am not familiar with what that is. Is there an
easier way to do this or can you tell me where to find the ThisDocument
module?

Thanks again.

  #5   Report Post  
Posted to microsoft.public.word.pagelayout
Ruben Torrez Ruben Torrez is offline
external usenet poster
 
Posts: 2
Default Text Fields in Header/Footer that prompts for user input

Great, that is really helpful. Thank you so much.
Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating dynamic cross reference links in a Word document torajudo Microsoft Word Help 5 April 27th 23 08:57 PM
What is the best way to set up this kind of formatting? [email protected] Microsoft Word Help 11 November 16th 06 11:40 PM
autoshape text wrapping cayce Page Layout 6 June 16th 06 09:42 PM
Outline Renee Hendershott Page Layout 2 December 25th 04 02:49 PM
posting data from text input fields to fields later in document BOB Microsoft Word Help 1 November 23rd 04 06:19 PM


All times are GMT +1. The time now is 06:27 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright 2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"