Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Word Merge Help...
Message
From
29/01/2008 10:59:30
Chris Sund
Silhouette Solutions
Utah, United States
 
 
To
29/01/2008 08:45:41
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Miscellaneous
Thread ID:
01286305
Message ID:
01286683
Views:
28
Cetin,

I appreciate your time. I have one additional question. I'm working on this now, and if I get it resolved, I'll let you know. For some reason the code is hanging on...
.OpenDataSource(m.lcSourceDoc) && Set file as data source for mailmerge
When I look at the "Task Manager" there's an item running that says "Header Record Delimiters".

I took your code, and adapted it slightly to work with information in my project. In the debugger m.lcsourceDoc points to the proper MergeSource.txt, and the MergeSource.txt has information in it.

Here's what the code looks like with my modifications...
CD c:\vpmapps\tlp
DEBUG
susp

Select cprimary_owner From data\owners Where .t. Into Cursor mergethese
brow &&& There is data in the browse

MergeIt('mergethese')

Function MergeIt
Lparameters  tcAlias, tcTemplateDoc
Local nLocaleID,lcTemp,lcHeader
Local loWord,llToPrinter,lcSourceDoc

*** 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

* Prepare source
Select (m.tcAlias)
lcTemp = Sys(2015)+'.tmp'
Copy To (lcTemp) Type Delimited With "" With Tab
AFIELDS(laFields)
lcHeader = ''
For ix = 1 To Fcount()
    lcHeader = lcHeader + ;
        Iif(Empty(m.lcHeader),'',Chr(9)) + ;
        Field(m.ix)
Endfor
lcSourceDoc = Sys(5)+Curdir()+'MergeSource.txt' &&& This file has data in it as well
Strtofile(m.lcHeader+Chr(13)+Chr(10)+Filetostr(m.lcTemp),m.lcSourceDoc)
Erase (m.lcTemp)

loWord=Createobject("word.application")	&& Create word object
With loWord
    If Empty(m.tcTemplateDoc) && No template
        .documents.Add()  && New file
    Else
        .documents.Add(m.lcTemplateDoc)  && Open a template
    Endif
    With .Activedocument.Mailmerge
        *.OpenDataSource("c:\vpmapps\tlp\MergeSource.txt") &&& I tried adding the actual path, but it didn't work. 
        .OpenDataSource(m.lcSourceDoc) && Hangs Here
        .EditMainDocument	&& Activate the main document

* Just to sample programmatic writing
        .Application.Selection.TypeText("Company : ")
        .Fields.Add(.Application.Selection.Range,'cprimary_owner')
        .Application.Selection.TypeText(Chr(13)+"Dear contact : ")
        .Fields.Add(.Application.Selection.Range,'cprimary_owner')
        .Application.Selection.TypeText(Chr(13)+"Blah blah ...."+Chr(13))
* Just to sample programmatic writing
*!*	FOR EACH oFld IN .Fields
*!*	? GETWORDNUM(oFld.Code.Text,2)
*!*	endfor
    Endwith
    .Visible = .T.  && Show word app
    .Activate  && Make it the active foreground app
Endwith

**** Set the LocaleId to the previous value
=Sys(3006,Val(nlLocaleId))
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform