Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #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
 



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 11:11 PM.


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