Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Word Merge Help...
Message
From
29/01/2008 16:07:39
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
29/01/2008 10:59:30
Chris Sund
Silhouette Solutions
Utah, United States
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Miscellaneous
Thread ID:
01286305
Message ID:
01286908
Views:
19
Chris,
I just tried that code under Office2007. I too thought it was hung on that line but it was working and after sometime it showed up in word. I don't know why it works so slow in word2007. MSOffice team likes making changes that break working code much than anyone else:(
Here is another code I tested and it was much faster, go figure (I couldn't see what is different really, probably overlooking something):
#include "wdconst.h"
Select cust_id, company,contact,country ;
	from (_samples+'data\customer') ;
	where country = 'USA' ;
	into Cursor Tempreport

lcTemp = FORCEPATH(Sys(2015)+'.tmp',SYS(2023))
lcSourceDoc = FORCEPATH('Source.txt',SYS(2023))

Copy To (lcTemp) Type Delimited With "" With Tab
lcHeader = chrtran('CustomerID,CompanyName,ContactName,Country',',',CHR(9))

Strtofile(m.lcHeader+Chr(13)+Chr(10)+;
	Filetostr(m.lcTemp),m.lcSourceDoc)
Erase (m.lcTemp)

*** set the LOCALEID to English
nlLocaleId=Sys(3004)  && Save local id
=Sys(3006,1033)       && We will be sending instructions in English
*** set the LOCALEID to English

Local oWordDocument, llToPrinter, lcTempDataDoc
oWord=Createobject("word.application")	&& Create word object
With oWord
	.documents.Add  && New file or open a template
	With .Activedocument.Mailmerge
		.OpenDataSource(m.lcSourceDoc) && Set file as data source for mailmerge
		.EditMainDocument	&& Activate the main document
	Endwith
	.Application.Selection.TypeText("Dear,"+Chr(13))
	With .Application.Selection.Font
		.Name = 'Times New Roman'
		.Italic = .T.
		.Size = 14
	Endwith
	.Activedocument.Mailmerge.Fields.Add(.Application.Selection.Range, 'ContactName')
	.Application.Selection.TypeText(Chr(13))
	.Activedocument.Mailmerge.Fields.Add(.Application.Selection.Range, 'CompanyName')
	.Application.Selection.TypeText(", ")
	.Activedocument.Mailmerge.Fields.Add(.Application.Selection.Range, 'Country')
	With .Application.Selection.Font
		.Italic = .F.
		.Name = 'Arial'
		.Size = 10
	Endwith
	.Application.Selection.TypeText(Chr(13)+"Blah blah")
	.Visible = .T.  && Show word app
	.Activate  && Make it the active foreground app
Endwith

**** Set the LocaleId to the previous value
=Sys(3006,Val(nlLocaleId))
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform