WITH loMerge.DataSource ---> .Name = "C:\MyFolder\MySpreadsheet.xls" .FirstRecord = 1 .LastRecord = lnLastrec * .LastRecord = 1 ENDWITHreplacing, of course, the value of .Name with the location of your desired spreadsheet file (which you may wish to pass in as another parameter).
ActiveDocument.MailMerge.DataSource.Name = "C:\MyFolder\MySpreadsheet.xls">>from the VFP side after handing it the letter name and before merging?
>llRetVal = .T. >loWord = CREATEOBJECT("Word.Application") > >* This was added to prevent the "Server threw an Exception" error >* on some Win XP / Office XP computers. >WAIT " " TIMEOUT .8 > >WITH loWord > loDocument = .Documents.Open(tcWordDoc) > loMerge = loDocument.MailMerge > WITH loMerge.DataSource > .FirstRecord = 1 > .LastRecord = lnLastrec > * .LastRecord = 1 > ENDWITH > WITH loMerge > .Destination = 0 > .Execute() > ENDWITH > loMerge = NULL > loDocument = NULL >ENDWITH > >loWord.Visible= .T. >* Bring Word to the front. >loWord.Activate() > >* .Destination = 0 Send output to New Document. >* .Destination = 1 Send output to Printer. > >*loWord.ActiveDocument.Close(0) >*loWord.Quit() >loWord = NULL >RETURN llRetVal >