Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Word mailmerge with excel error
Message
De
09/07/2007 19:19:36
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
09/07/2007 16:24:46
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Divers
Thread ID:
01238712
Message ID:
01238744
Vues:
12
>I am trying to use an excel file (created by a sql select and copy to ... type xls)
>as a data source for my mail merge and I get a 'file not in the expected format' error
>what am I doing wrong??
>
>
>also what is the value of : wdOpenFormatAuto ?? it's not in my word10.h
>
>
>
>
>lcSourceDoc = SYS(5)+CURDIR()+'Source.xls'
>
>
>oWord=CREATEOBJECT("word.application")	&& Create word object
>WITH oWord
>	.documents.ADD
>	WITH .ActiveDocument.Mailmerge
>		.OpenDataSource(m.lcSourceDoc) && Set file as data source for mailmerge
>		.EditMainDocument	&& Activate the main document
>		.OpenDataSource(lcSourceDoc , False,False,true,False,"","","","",False,wdOpenFormatAuto,"Entire Spreadsheet","","",wdMergeSubTypeOther)
>
>		.FIELDS.ADD(oWord.SELECTION.RANGE, NAME:= _
>		"fullname"
>		SELECTION.TypeParagraph
>		.FIELDS.ADD(oWord.SELECTION.RANGE, "last_name")
>		oWord.SELECTION.TypeParagraph
>		.FIELDS.ADD(oWord.SELECTION.RANGE,"first_name")
>		oWord.SELECTION.TypeParagraph
>		.FIELDS.ADD(oWord.SELECTION.RANGE,"middle_name")
>		oWord.SELECTION.TypeParagraph
>		.FIELDS.ADD(oWord.SELECTION.RANGE,"salutation")
>		oWord.SELECTION.TypeParagraph
>		.FIELDS.ADD(oWord.SELECTION.RANGE,"hcity")
>		oWord.SELECTION.TypeParagraph
>		.FIELDS.ADD(oWord.SELECTION.RANGE,"hstate")
>		oWord.SELECTION.TypeParagraph
>		.FIELDS.ADD(oWord.SELECTION.RANGE,"hzip")
>		oWord.SELECTION.TypeParagraph
>		.FIELDS.ADD(oWord.SELECTION.RANGE,"phonenumber")
>		oWord.SELECTION.TypeParagraph
>		.FIELDS.ADD(oWord.SELECTION.RANGE,"email")
>		oWord.SELECTION.TypeParagraph
>		.FIELDS.ADD(oWord.SELECTION.RANGE,"company")
>	ENDWITH
>ENDWITH
>WITH oWord.ActiveDocument.Mailmerge
>	.Destination = wdSendToNewDocument
>	.SuppressBlankLines = true
>	WITH .DATASOURCE
>		.FirstRecord = wdDefaultFirstRecord
>		.LastRecord = wdDefaultLastRecord
>	ENDWITH
>	.Execute(False)
>ENDWITH
>
>
>
>Thanks
>
>Peter

Got using object browser:
#DEFINE wdOpenFormatAuto	0	
#DEFINE wdOpenFormatDocument	1	
#DEFINE wdOpenFormatTemplate	2	
#DEFINE wdOpenFormatRTF	3	
#DEFINE wdOpenFormatText	4	
#DEFINE wdOpenFormatUnicodeText	5	
#DEFINE wdOpenFormatEncodedText	5	
#DEFINE wdOpenFormatAllWord	6	
#DEFINE wdOpenFormatWebPages	7	
#DEFINE wdOpenFormatXML	8	
Peter,
Wasn't that code originally using the easier txt or doc as source? IMHO use one of them instead of Excel.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform