LetterContent Object
Description
Represents the elements of a letter created by the Letter Wizard.
Using the LetterContent Object
Use the GetLetterContent method or the CreateLetterContent method to return a LetterContent object. The following example retrieves and displays the letter recipient's name from the active document.
Set myLetterContent = ActiveDocument.GetLetterContent
MsgBox myLetterContent.RecipientName
The following example uses the CreateLetterContent method to create a new LetterContent object, which is then used with the RunLetterWizard method.
Set myLetter = ActiveDocument.CreateLetterContent(DateFormat:="July 11, 1996", _
IncludeHeaderFooter:=False, _
PageDesign:="C:\MSOffice\Templates\Letters & Faxes\Contemporary Letter.dot", _
LetterStyle:=wdFullBlock, Letterhead:=True, LetterheadLocation:=wdLetterTop, _
LetterheadSize:=InchesToPoints(1.5), RecipientName:="Dave Edson", _
RecipientAddress:="100 Main St." & vbCr & "Bellevue, WA 98004", _
Salutation:="Dear Dave,", SalutationType:=wdSalutationInformal, _
RecipientReference:="", MailingInstructions:="", AttentionLine:="", _
Subject:="End of year report", CCList:="", ReturnAddress:="", _
SenderName:="", Closing:="Sincerely yours,", SenderCompany:="", _
SenderJobTitle:="", SenderInitials:="", EnclosureNumber:=0)
ActiveDocument.RunLetterWizard LetterContent:=myLetter, WizardMode:=True
Remarks
The CreateLetterContent method creates a LetterContent object; however, there are numerous required arguments. If you want to set only a few properties, use the New keyword to create a new, stand-alone LetterContent object. The following example creates a LetterContent object, sets some of its properties, and then uses the LetterContent object with the RunLetterWizard method to run the Letter Wizard, using the preset values as the default settings.
Set myLetter = New LetterContent
With myLetter
.AttentionLine = "Read this"
.EnclosureNumber = 1
.Letterhead = True
.LetterheadLocation = wdLetterTop
.LetterheadSize = InchesToPoints(2)
End With
Documents.Add.RunLetterWizard LetterContent:=myLetter, WizardMode:=True
You can duplicate a LetterContent object by using the Duplicate property. The following example retrieves the letter elements in the active document and makes a duplicate copy. The example assigns the duplicate copy to aLetter and resets the recipient's name and address to empty strings. The RunLetterWizard method is used to run the Letter Wizard, using the values in the revised LetterContent object (aLetter) as the default settings.
Set aLetter = ActiveDocument.GetLetterContent.Duplicate
With aLetter
.RecipientName = ""
.RecipientAddress = ""
Documents.Add.RunLetterWizard LetterContent:=aLetter, WizardMode:=True
The SetLetterContent method inserts the contents of the specified LetterContent object in a document. The following example retrieves the letter elements from the active document, changes the attention line, and then uses the SetLetterContent method to update the active document to reflect the change.
Set myLetterContent = ActiveDocument.GetLetterContent
myLetterContent.AttentionLine = "Greetings"
ActiveDocument.SetLetterContent LetterContent:=myLetterContent
Properties
Application property, AttentionLine property, CCList property, Closing property, Creator property, DateFormat property, Duplicate property, EnclosureNumber property, IncludeHeaderFooter property, InfoBlock property, Letterhead property, LetterheadLocation property, LetterheadSize property, LetterStyle property, MailingInstructions property, PageDesign property, Parent property, RecipientAddress property, RecipientCode property, RecipientGender property, RecipientName property, RecipientReference property, ReturnAddress property, ReturnAddressShortForm property, Salutation property, SalutationType property, SenderCity property, SenderCode property, SenderCompany property, SenderGender property, SenderInitials property, SenderJobTitle property, SenderName property, SenderReference property, Subject property.