Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Word mailmerge with excel error
Message
De
09/07/2007 19:31:46
 
 
À
09/07/2007 19:19:36
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
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:
01238745
Vues:
6
That's the conclusion I came to too.
I'll try txt. how come XML is not on the top of the list nowadays?
thanks
what is the txt format like?


Peter

>>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
Peter Cortiel
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform