Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
MailMerge Word
Message
From
21/06/2010 09:38:01
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
19/06/2010 13:38:29
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Miscellaneous
Thread ID:
01469656
Message ID:
01469872
Views:
57
>>>Hi,
>>>
>>>I would like to build a mailmerge with a Word document. Have tried to make use of the mailmrge.vcx in solutions and faced an error to which I dont have an answer:
>>> In preparedate method: "Cannot open data table for share use."
>>>
>>> I am using a cursor to fill the aflds.
>>>Anybody to show me how to solve this?
>>>
>>>Regards,
>>>
>>>Koen
>>
>>This works up to Office 2010 64 bits:
>>
>>http://www.tek-tips.com/viewthread.cfm?qid=1581222&page=3
>>
>>Cetin
>
>Hi,
>
>I have a local cursor and work with an already prepared Word document.
>The fieldnames of my cursor tally with the field names in my Word (template) document.
>I am able to make a mailmerge by 'hand' by means of a) export my local cursor to an Exel file and than b) mailmerge myu WordDocument and the Excel sheet with the Word mailmerge module. I would like to automate that process in my VFP application.
>When I use your Procedure, I get an wait windo "Preparing Word document.Please wait..." Nothing apearently happens, I cant cancel - remains Ctrl-Alt-Delteand , I kill VFP and are confronted with a window of Word - prompting me to to give the field delimeters no use to give a delimeter as VFP already killed.
>Obviously I am either doing something wrong with passing the paramaters to your procedure or doing something wrong with preparing the Word (Template) document.
>Some assistance would be nice.
>
>VFP9Sp2 - Word2007.doc XP or VFP9Sp2 Win7 Word2010.doc no difference same situation.
>
>Regards,
>
>Koen

It doesn't matter if you have a ready template (and actually it is the preferred way of working with mailmerge). You simply use that template's filename as a parameter to Documents.Add() method.
In that sample it is directly using VFPOLEDB and doing an SQL against VFP backend. VFPOLEDB cannot access in memory cursors. Instead you would supply the SQL that generates that cursor. If you can't do that then do not even attempt to use VFP tables as a backend to OpenDataSource. In that case you could simply save as a tab delimited or CSV text file and use that as OpenDataSource() parameter. You can find many samples here if you search using keywords "MailMerge OpenDataSource cetin" - set start year to 1996.
PS: Found one of them for you:
Re: Word mailmerge with excel error Thread #1238712 Message #1238813
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
Reply
Map
View

Click here to load this message in the networking platform