Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling MS-Word LetterWizard 1

Status
Not open for further replies.

BongoB1

Programmer
Jul 26, 2001
26
0
0
US
I would like feed name and address info out of FoxPro into MS-Word's LetterWizard to allow a client to automatically start a new letter. I have looked at the MS-Word help where they talk about using the CreateLetterContent method to create a LetterContent object, but this requires filling in all of the arguments when I only want to fill in a few. They suggest, "If you want to set only a few properties, use the New keyword to create a new, stand-alone LetterContent object." I don't understand how to translate the VB example they give,

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

Thanks
 
BongoB1

Is this what you are looking for?
Code:
LOCAL oWord as word.application
oWord= CREATEOBJECT("word.application")
oDoc = oword.Documents.Add("C:\Program Files\Microsoft Office\Templates\1033\Contemporary Letter.dot")
oword.Visible =.t.

Adjust the path as required.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Cut-n-paste the code below into a prg file and run it from within VFP...let me know if this is what you were trying to do...I've only filled out a few of the fields, you could fill out more or less depending on your needs:

PUBLIC oWord, oLetterContent
oWord=Createobject("Word.Application")
oWord.Documents.Add()
oLetterContent = oWord.Documents(1).GetLetterContent()
With oLetterContent
.RecipientName ="John Smith"
.RecipientAddress ="555 Oak Lane Road" +CHR(13) +CHR(10) + "Someplace, MN 55555"
.Salutation = "Dear John"
ENDWITH
oWord.visible = .t.
oWord.Documents(1).RunLetterWizard(oLetterContent,.T.)

Slighthaze = NULL

[ul][li]FAQ184-2483
An excellent guide to getting a fast and accurate response to your questions in this forum.[/li][/ul]
 
Slighthaze,

That is exactly what I want to do. Thank you so very much.

This is worth several stars.

:cool:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top