Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Word Automation Tribulation
Message
From
17/11/2001 10:20:27
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00583019
Message ID:
00583115
Views:
29
This message has been marked as a message which has helped to the initial question of the thread.
>Hello everyone,
>
>I am trying to stop the message dialog 'Confirm Data Source' from appearing in MCS Word during my mail merge. Once there, I select 'Foxpro Files - Word Via ODBC(*.dbf)', which I would like to specify/bypass through code.
>
>I suspect I must add something to this statement from my program:
>
>oMCSWord.activedocument.mailmerge.opendatasource('c:\vfpwork\prtwork',)
>
>I used Word macros and viewed the code where I saw a 'sourcetype=DBF' statement and tried to add that to my code without success.
>
>Also tried to bypass ODBC but need to use it to merge memo fields (I think).
>
>Help!

Todd,
OpenDataSource needs an ODBC connection string with DSN. ie :
#Define MYDBC _samples+"\DATA\testdata.DBC"
#Define wdSendToEmail  2
#Define wdSendToFax  3
#Define wdSendToNewDocument  0
#Define wdSendToPrinter  1
cSQLStatement1 = "SELECT * FROM employee where title like [Sales%]"
cSQLStatement2 = ""

* Be carefull with where clause - where title = [Sales] fails
* for ODBC uses ANSI SQL (exact match)
* Two strings for first is limited to 255 chars

oWordDocument=createobject("word.application")	&& Create word object
With oWordDocument
  .Documents.Add(sys(5)+curdir()+'mmerge.dot') && Use a predefined template
  With .ActiveDocument.MailMerge
    .OpenDataSource(,,,.T.,,,,,,,, ;
      "DSN=Visual FoxPro Database;SourceDB="+MYDBC+;
      ";SourceType=DBC;Exclusive=No;",;
      cSQLStatement1, cSQLStatement2) && Open data source - Link to source
    .Destination = wdSendToNewDocument
    .Execute
  Endwith
  .Visible = .t.
Endwith
Sourcetype=DBF is dangerous if your data has memo and probably would fail anywhere where MDAC2.1 or later is installed.
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