Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-22-2015, 10:20 PM
Shanna86 Shanna86 is offline Generating a Letter Windows 7 32bit Generating a Letter Office 2013
Novice
Generating a Letter
 
Join Date: Sep 2015
Posts: 5
Shanna86 is on a distinguished road
Default 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
Reply With Quote
  #2  
Old 09-22-2015, 10:36 PM
gmayor's Avatar
gmayor gmayor is offline Generating a Letter Windows 7 64bit Generating a Letter Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

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
Reply With Quote
  #3  
Old 09-23-2015, 12:27 PM
Shanna86 Shanna86 is offline Generating a Letter Windows 7 32bit Generating a Letter Office 2013
Novice
Generating a Letter
 
Join Date: Sep 2015
Posts: 5
Shanna86 is on a distinguished road
Default

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.
Reply With Quote
  #4  
Old 09-23-2015, 04:03 PM
Charles Kenyon Charles Kenyon is offline Generating a Letter Windows 8 Generating a Letter Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,125
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

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
Reply With Quote
  #5  
Old 09-23-2015, 07:30 PM
Shanna86 Shanna86 is offline Generating a Letter Windows 7 32bit Generating a Letter Office 2013
Novice
Generating a Letter
 
Join Date: Sep 2015
Posts: 5
Shanna86 is on a distinguished road
Default

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.
Reply With Quote
  #6  
Old 09-23-2015, 09:14 PM
gmayor's Avatar
gmayor gmayor is offline Generating a Letter Windows 7 64bit Generating a Letter Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

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
Reply With Quote
  #7  
Old 09-28-2015, 09:46 PM
Shanna86 Shanna86 is offline Generating a Letter Windows 7 32bit Generating a Letter Office 2013
Novice
Generating a Letter
 
Join Date: Sep 2015
Posts: 5
Shanna86 is on a distinguished road
Default

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
Reply With Quote
  #8  
Old 09-28-2015, 10:54 PM
gmayor's Avatar
gmayor gmayor is offline Generating a Letter Windows 7 64bit Generating a Letter Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

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
Reply With Quote
  #9  
Old 09-29-2015, 09:18 AM
Shanna86 Shanna86 is offline Generating a Letter Windows 7 32bit Generating a Letter Office 2013
Novice
Generating a Letter
 
Join Date: Sep 2015
Posts: 5
Shanna86 is on a distinguished road
Default

Slightly lost on how to name things. Currently my form has "var1" as the recipient's name

Quote:
Private Sub CommandButton1_Click()
'Define the variable oVars
Set oVars = ActiveDocument.Variables
'Hide the userform
Me.Hide
'Assign the values of the seven text boxes to the seven variables
oVars("var1").Value = Me.TextBox1.Value
oVars("var2").Value = Me.TextBox2.Value
oVars("var3").Value = Me.TextBox3.Value
oVars("var4").Value = Me.TextBox4.Value
oVars("var5").Value = Me.TextBox5.Value
oVars("var6").Value = Me.TextBox6.Value
oVars("var7").Value = Me.TextBox7.Value
'Update the fields in the body of the document
'Fields in other parts of the document will probably require extra code
'See http://www.gmayor.com/installing_macro.htm
ActiveDocument.Fields.Update
'Clear the variable
Set oVars = Nothing
'Unload the form
Unload Me
End Sub

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:
Public Sub FillBM(strBMName As String, strValue As String)
'Graham Mayor
Dim oRng As Range
With ActiveDocument
On Error GoTo lbl_Exit
Set oRng = .Bookmarks(strBMName).Range
oRng.Text = strValue
oRng.Bookmarks.Add strBMName
End With
lbl_Exit:
Set oRng = Nothing
Exit Sub
End Sub
What part do I change to reflect the value from my textbox?

Last edited by Shanna86; 09-29-2015 at 09:23 AM. Reason: fixing
Reply With Quote
  #10  
Old 09-29-2015, 09:11 PM
gmayor's Avatar
gmayor gmayor is offline Generating a Letter Windows 7 64bit Generating a Letter Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

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
Reply With Quote
Reply



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 a Letter generating visual reports ketanco Project 1 07-19-2014 12:01 PM
Generating a Letter 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

Other Forums: Access Forums

All times are GMT -7. The time now is 08:04 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft