#1
|
|||
|
|||
Generating a Letter
Hi all,
I'm very new here and have a question about creating a document. I'm certainly willing to learn about advanced options/techniques in Word but I thought I would see if what I'm trying to do is even possible first. At work we use Office 2013 and I am trying to write letters in Word. There are a few things I'd like to do in hopes of speeding up the process. I'd like to have a form where I can type a person's name in once and it will be filled in throughout the form. Currently I use "find and replace" for that by using previous letters as a template for a new letter and what works well. What would be great would be an easy way to change pronouns. If I have a blank form is there a way to populate fields with the correct pronouns? Maybe through a prompt that will fill in "he" in the places I specify and then "him" in places, etc.? I suppose I could have a template that has a pronoun placeholder and I could use find and replace again to insert the correct words. I think the hardest thing I'd like to do is insert long pieces of text. Say in a letter there are 5 possible topics I typically cover and in this letter I want to cover topic 2 and 4. I could just have the language pre-written somewhere and I could copy and paste it in as needed. I'm wondering if there's a different way. Like typing in a phrase/code would insert text? I had thought autocorrect would work, like typing ".topic1" would insert what I need but there's a character limit. Is there another feature somewhere that doesn't have a character limit? I'm sure names and pronouns are easy enough to sort out but my dream form letter would be something that opens with a series of prompts or check boxes where I could just fill in the name, gender, and topics needed and the letter would basically write itself! Thanks for any insight on this issue |
#2
|
||||
|
||||
All is possible. The most elegant approach is to create a userform to drive the document. Start by looking at http://www.gmayor.com/Userform.htm and for a more in depth explanation, see http://gregmaxey.com/Create_and_employ_a_UserForm.htm
Long texts can be inserted from separate documents or from building blocks according to selections, even hard coded in the macro - see http://www.gmayor.com/SelectFile.htm There is no character limit with formatted autocorrect. You can insert many pages of text and graphics with autocorrect, but I wouldn't use it for this task.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
Thanks for the quick reply Graham!
I started reading through the links last night and worked on a template this morning. So far so good! Hopefully this speeds up my letter writing so I can spend time on other things. |
#4
|
|||
|
|||
Another option for long text inserts is AutoText, either directly inserted or using an AutoText Field link. Automated Boilerplate Using Microsoft Word
One of my favorite methods of referencing is the StyleRef Field. An even better method, if you are willing to spend the time on it is to have linked Content Controls. Word Content Controls CC⁄V⁄BM & DP Tools Add-in You may also want to look at: Setting Up Letter Templates |
#5
|
|||
|
|||
Follow up newbie question: I set up a userform this morning and saved it to the normal template as seen in the UserForm tutorial. I tested the macro with dummy text and it all worked fine. This evening I decided to test it out with a real letter and the macro isn't showing up anywhere in the list, whether I go to "all" "normal" "MyTemplateFile," etc. If I open the VBA editor I can see UserForm1 listed under forms, I can view the object, but I can't run a process to make it pop up and fill in the text.
Did I miss something in the save instructions? It's not going to do much good to have a form I can't open when I make a new file from the template. |
#6
|
||||
|
||||
For a document template, the userform and the macro that drives it should go in the document template and not the normal template. However it can work for any document in the normal template.
The simple userform example from the link contains all the code relating to the userform, however, as mentioned on the linked page, you need to to call the form from the document/template. This is done from a simple macro in a project module. http://www.gmayor.com/installing_macro.htm Option Explicit Sub ShowMyForm() UserForm1.Show Unload UserForm1 End Sub If you want the form to display automatically when you create new documents from the template, create an autonew macro in the template to call the above macro e.g. Sub AutoNew() ShowMyForm End Sub This however relates to document templates only as you don't want the form popping up every time you create a document from the normal template
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#7
|
|||
|
|||
I was just misunderstanding the last bit about the module, so that fixed the problem, thank you! I've been doing more reading and testing and have some additional questions.
Do you know if userforms don't apply to document headers? In the past if I used an old letter as a template for a new one, I would use "find and replace" to swap names, which included the recipient's name in the header. When I fill in my form with the name and other relevant info, the name shows up perfectly throughout the document except in the header. Is there a way to fix that? Also, does anyone know of some good tutorials on check boxes and inserting information by checking a box? I read through a few guides already but they're either not what I'm looking to do or way over my head. I'd like to have a second form where I can check which "flavor" the letter recipient has chosen. I could do autocorrect and just have a nickname to insert information on each flavor but there's like 20 so it's not practical. The guide on "select file" was sort of what I was looking for but I wasn't following the autotext section. I was getting the impression the checkbox was in the actual document text but I was aiming for a separate window where I can check the needed flavor and the correct text will be inserted where I tell it to go. Where I think I'm stuck is how to connect the checkbox to a particular autotext entry and getting it to be inserted at a specified place in the document. I'm 100% new to this and I'm sure it's just a matter of understanding the coding but I'm not there yet. Last edited by Shanna86; 09-28-2015 at 09:48 PM. Reason: clarification |
#8
|
||||
|
||||
You can address any part of the document from the userform, by setting a range to the area you wish to work in. If you put a bookmark in the header e.g. bmHeader then you can write text to that bookmark using the FillBM function you will find at http://www.gmayor.com/useful_vba_functions.htm then call it from your macro as follows
Code:
FillBM "bmHeader", "Some Text"
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#9
|
|||
|
|||
Slightly lost on how to name things. Currently my form has "var1" as the recipient's name
Quote:
EDIT: Sorry, hadn't reviewed the link you put in yet. I looked at the instructions for FillBM, just trying to figure out how to name it for the right value. From what you have: Quote:
Last edited by Shanna86; 09-29-2015 at 09:23 AM. Reason: fixing |
#10
|
||||
|
||||
You are mixing techniques here. Either bookmarks or docvariables can be used. Your originally quoted macro used docvariables. FillBM is for bookmarks.
To reproduce the values in your document use Docvariable fields i.e. Type CTRL+F9 to give you {} then between type { DOCVARIABLE var1 }. When the macro is run that field will display the value you entered in the associated text box. If instead you were using bookmarks, then but a bookmark (say) bm1 where you want the information displayed then call the function from the userform e.g. FillBM "bm1", Me.TextBox1.Text to write the cointent of the text box to the bookmarked location.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to replace a letter to random letter with different color? | cikanoz87 | Word | 7 | 06-18-2015 09:43 PM |
generating visual reports | ketanco | Project | 1 | 07-19-2014 12:01 PM |
generating a number in Word | John P | Word | 1 | 05-31-2012 10:29 PM |
Generating Buy/Sell signals accordingly... | babapusy | Excel | 0 | 04-14-2012 10:11 AM |
MS Word 2003 – Generating a ToC | krazykasper | Word | 1 | 04-29-2009 02:44 PM |