Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.pagelayout
|
|||
|
|||
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
Posted to microsoft.public.word.pagelayout
|
|||
|
|||
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
Posted to microsoft.public.word.pagelayout
|
|||
|
|||
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
Posted to microsoft.public.word.pagelayout
|
|||
|
|||
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
Posted to microsoft.public.word.pagelayout
|
|||
|
|||
Text Fields in Header/Footer that prompts for user input
Great, that is really helpful. Thank you so much.
|
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Creating dynamic cross reference links in a Word document | Microsoft Word Help | |||
What is the best way to set up this kind of formatting? | Microsoft Word Help | |||
autoshape text wrapping | Page Layout | |||
Outline | Page Layout | |||
posting data from text input fields to fields later in document | Microsoft Word Help |