DocumentBase.CreateLetterContent Method
Creates and returns a LetterContent object based on the specified letter elements.
Namespace: Microsoft.Office.Tools.Word
Assembly: Microsoft.Office.Tools.Word.v4.0.Utilities (in Microsoft.Office.Tools.Word.v4.0.Utilities.dll)
Syntax
'Declaration
Public Function CreateLetterContent ( _
dateFormat As String, _
includeHeaderFooter As Boolean, _
pageDesign As String, _
letterStyle As WdLetterStyle, _
letterhead As Boolean, _
letterheadLocation As WdLetterheadLocation, _
letterheadSize As Single, _
recipientName As String, _
recipientAddress As String, _
salutation As String, _
salutationType As WdSalutationType, _
recipientReference As String, _
mailingInstructions As String, _
attentionLine As String, _
subject As String, _
cCList As String, _
returnAddress As String, _
senderName As String, _
closing As String, _
senderCompany As String, _
senderJobTitle As String, _
senderInitials As String, _
enclosureNumber As Integer, _
ByRef infoBlock As Object, _
ByRef recipientCode As Object, _
ByRef recipientGender As Object, _
ByRef returnAddressShortForm As Object, _
ByRef senderCity As Object, _
ByRef senderCode As Object, _
ByRef senderGender As Object, _
ByRef senderReference As Object _
) As LetterContent
public LetterContent CreateLetterContent(
string dateFormat,
bool includeHeaderFooter,
string pageDesign,
WdLetterStyle letterStyle,
bool letterhead,
WdLetterheadLocation letterheadLocation,
float letterheadSize,
string recipientName,
string recipientAddress,
string salutation,
WdSalutationType salutationType,
string recipientReference,
string mailingInstructions,
string attentionLine,
string subject,
string cCList,
string returnAddress,
string senderName,
string closing,
string senderCompany,
string senderJobTitle,
string senderInitials,
int enclosureNumber,
ref Object infoBlock,
ref Object recipientCode,
ref Object recipientGender,
ref Object returnAddressShortForm,
ref Object senderCity,
ref Object senderCode,
ref Object senderGender,
ref Object senderReference
)
Parameters
dateFormat
Type: System.StringThe date for the letter.
includeHeaderFooter
Type: System.Booleantrue to include the header and footer from the page design template.
pageDesign
Type: System.StringThe name of the template attached to the document.
letterStyle
Type: Microsoft.Office.Interop.Word.WdLetterStyleA WdLetterStyle. The document layout.
letterhead
Type: System.Booleantrue to reserve space for a preprinted letterhead.
letterheadLocation
Type: Microsoft.Office.Interop.Word.WdLetterheadLocationA WdLetterheadLocation. The location of the preprinted letterhead.
letterheadSize
Type: System.SingleThe amount of space (in points) to be reserved for a preprinted letterhead.
recipientName
Type: System.StringThe name of the person receiving the letter.
recipientAddress
Type: System.StringThe mailing address of the person receiving the letter.
salutation
Type: System.StringThe salutation text for the letter.
salutationType
Type: Microsoft.Office.Interop.Word.WdSalutationTypeA WdSalutationType. The salutation type for the letter.
recipientReference
Type: System.StringThe reference line text for the letter (for example, "In reply to:").
mailingInstructions
Type: System.StringThe mailing instruction text for the letter (for example, "Certified Mail").
attentionLine
Type: System.StringThe attention line text for the letter (for example, "Attention:").
subject
Type: System.StringThe subject text for the specified letter.
cCList
Type: System.StringThe names of the carbon copy (CC) recipients for the letter.
returnAddress
Type: System.StringThe text of the return mailing address for the letter.
senderName
Type: System.StringThe name of the person sending the letter.
closing
Type: System.StringThe closing text for the letter.
senderCompany
Type: System.StringThe company name of the person creating the letter.
senderJobTitle
Type: System.StringThe job title of the person creating the letter.
senderInitials
Type: System.StringThe initials of the person creating the letter.
enclosureNumber
Type: System.Int32The number of enclosures for the letter.
infoBlock
Type: System.Object%This argument might not be available to you, depending on the language support (U.S. English, for example) that you selected or installed.
recipientCode
Type: System.Object%This argument might not be available to you, depending on the language support (U.S. English, for example) that you selected or installed.
recipientGender
Type: System.Object%This argument might not be available to you, depending on the language support (U.S. English, for example) that you selected or installed.
returnAddressShortForm
Type: System.Object%This argument might not be available to you, depending on the language support (U.S. English, for example) that you selected or installed.
senderCity
Type: System.Object%This argument might not be available to you, depending on the language support (U.S. English, for example) that you selected or installed.
senderCode
Type: System.Object%This argument might not be available to you, depending on the language support (U.S. English, for example) that you selected or installed.
senderGender
Type: System.Object%This argument might not be available to you, depending on the language support (U.S. English, for example) that you selected or installed.
senderReference
Type: System.Object%This argument might not be available to you, depending on the language support (U.S. English, for example) that you selected or installed.
Return Value
Type: Microsoft.Office.Interop.Word.LetterContent
A LetterContent based on the specified letter elements.
Remarks
Optional Parameters
For information on optional parameters, see Optional Parameters in Office Solutions.
Examples
The following code example gets a LetterContent by calling the CreateLetterContent method, and then sends this LetterContent as a parameter to the RunLetterWizard method. To use this example, run it from the ThisDocument class in a document-level project.
Private Sub DocumentRunLetterWizard()
Dim LetterContent As Object = Me.CreateLetterContent( _
DateFormat:=DateTime.Now.ToShortDateString(), IncludeHeaderFooter:=False, _
PageDesign:=String.Empty, LetterStyle:=Word.WdLetterStyle.wdFullBlock, _
Letterhead:=True, LetterheadLocation:=Word.WdLetterheadLocation.wdLetterTop, _
LetterheadSize:=25, RecipientName:="Don Hall", _
RecipientAddress:="100 Main St." + ControlChars.NewLine + "AnyTown, USA", _
Salutation:="Dear Dave,", SalutationType:=Word.WdSalutationType.wdSalutationInformal, _
RecipientReference:=String.Empty, MailingInstructions:=String.Empty, _
AttentionLine:=String.Empty, Subject:="End of year report", CCList:=String.Empty, _
ReturnAddress:=String.Empty, SenderName:=String.Empty, Closing:="Sincerely yours,", _
SenderCompany:=String.Empty, SenderJobTitle:=String.Empty, _
SenderInitials:=String.Empty, EnclosureNumber:=0)
Me.RunLetterWizard(LetterContent, True)
Me.SetLetterContent(LetterContent)
End Sub
private void DocumentRunLetterWizard()
{
object LetterContent = this.CreateLetterContent(
DateTime.Now.ToShortDateString(), false,
String.Empty, Word.WdLetterStyle.wdFullBlock, true,
Word.WdLetterheadLocation.wdLetterTop, 24, "Don Hall",
"100 Main St.\nAnytown, USA",
"Dear Dave,", Word.WdSalutationType.wdSalutationInformal,
String.Empty, String.Empty, String.Empty, "End of year report",
String.Empty, String.Empty, String.Empty, "Sincerely yours,",
String.Empty, String.Empty, String.Empty, 0, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing);
object WizardMode = true;
this.RunLetterWizard(ref LetterContent, ref WizardMode);
this.SetLetterContent(ref LetterContent);
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.