Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Word mailmerge with excel error
Message
De
09/07/2007 16:24:46
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Titre:
Word mailmerge with excel error
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Divers
Thread ID:
01238712
Message ID:
01238712
Vues:
73
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
Peter Cortiel
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform