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

  • includeHeaderFooter
    Type: System.Boolean

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

  • pageDesign
    Type: System.String

    The name of the template attached to the document.

  • letterStyle
    Type: WdLetterStyle

    A WdLetterStyle. The document layout.

  • letterhead
    Type: System.Boolean

    true to reserve space for a preprinted letterhead.

  • letterheadLocation
    Type: WdLetterheadLocation

    A WdLetterheadLocation. The location of the preprinted letterhead.

  • letterheadSize
    Type: System.Single

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

  • recipientName
    Type: System.String

    The name of the person receiving the letter.

  • recipientAddress
    Type: System.String

    The mailing address of the person receiving the letter.

  • salutation
    Type: System.String

    The salutation text for the letter.

  • salutationType
    Type: WdSalutationType

    A WdSalutationType. The salutation type for the letter.

  • recipientReference
    Type: System.String

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

  • mailingInstructions
    Type: System.String

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

  • attentionLine
    Type: System.String

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

  • subject
    Type: System.String

    The subject text for the specified letter.

  • cCList
    Type: System.String

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

  • returnAddress
    Type: System.String

    The text of the return mailing address for the letter.

  • senderName
    Type: System.String

    The name of the person sending the letter.

  • senderCompany
    Type: System.String

    The company name of the person creating the letter.

  • senderJobTitle
    Type: System.String

    The job title of the person creating the letter.

  • senderInitials
    Type: System.String

    The initials of the person creating the letter.

  • enclosureNumber
    Type: System.Int32

    The 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: 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

See Also

Reference

DocumentBase Class

Microsoft.Office.Tools.Word Namespace