Condividi tramite


DocumentBase.CreateLetterContent Method

Definition

Creates and returns a LetterContent object based on the specified letter elements.

public Microsoft.Office.Interop.Word.LetterContent CreateLetterContent (string dateFormat, bool includeHeaderFooter, string pageDesign, Microsoft.Office.Interop.Word.WdLetterStyle letterStyle, bool letterhead, Microsoft.Office.Interop.Word.WdLetterheadLocation letterheadLocation, float letterheadSize, string recipientName, string recipientAddress, string salutation, Microsoft.Office.Interop.Word.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);
member this.CreateLetterContent : string * bool * string * Microsoft.Office.Interop.Word.WdLetterStyle * bool * Microsoft.Office.Interop.Word.WdLetterheadLocation * single * string * string * string * Microsoft.Office.Interop.Word.WdSalutationType * string * string * string * string * string * string * string * string * string * string * string * int * obj * obj * obj * obj * obj * obj * obj * obj -> Microsoft.Office.Interop.Word.LetterContent
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, Optional ByRef infoBlock As Object, Optional ByRef recipientCode As Object, Optional ByRef recipientGender As Object, Optional ByRef returnAddressShortForm As Object, Optional ByRef senderCity As Object, Optional ByRef senderCode As Object, Optional ByRef senderGender As Object, Optional ByRef senderReference As Object) As LetterContent

Parameters

dateFormat
String

The date for the letter.

includeHeaderFooter
Boolean

true to include the header and footer from the page design template.

pageDesign
String

The name of the template attached to the document.

letterStyle
WdLetterStyle

A WdLetterStyle. The document layout.

letterhead
Boolean

true to reserve space for a preprinted letterhead.

letterheadLocation
WdLetterheadLocation

A WdLetterheadLocation. The location of the preprinted letterhead.

letterheadSize
Single

The amount of space (in points) to be reserved for a preprinted letterhead.

recipientName
String

The name of the person receiving the letter.

recipientAddress
String

The mailing address of the person receiving the letter.

salutation
String

The salutation text for the letter.

salutationType
WdSalutationType

A WdSalutationType. The salutation type for the letter.

recipientReference
String

The reference line text for the letter (for example, "In reply to:").

mailingInstructions
String

The mailing instruction text for the letter (for example, "Certified Mail").

attentionLine
String

The attention line text for the letter (for example, "Attention:").

subject
String

The subject text for the specified letter.

cCList
String

The names of the carbon copy (CC) recipients for the letter.

returnAddress
String

The text of the return mailing address for the letter.

senderName
String

The name of the person sending the letter.

closing
String

The closing text for the letter.

senderCompany
String

The company name of the person creating the letter.

senderJobTitle
String

The job title of the person creating the letter.

senderInitials
String

The initials of the person creating the letter.

enclosureNumber
Int32

The number of enclosures for the letter.

infoBlock
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
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
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
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
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
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
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
Object

This argument might not be available to you, depending on the language support (U.S. English, for example) that you selected or installed.

Returns

A LetterContent based on the specified letter elements.

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 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);
}
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

Remarks

Optional Parameters

For information on optional parameters, see Optional Parameters in Office Solutions.

Applies to