Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Word automation to unlimited number of items
Message
From
13/06/2002 08:06:39
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
13/06/2002 01:31:18
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00667775
Message ID:
00667850
Views:
15
This message has been marked as the solution to the initial question of the thread.
>I have a Word automation to do. I am sending the result in 3 columns. Basically, it's one field in a specific Word font followed by a second field, on the next line, with a smaller font. So, I have defined two fields. This is good as long as I only have record. However, the number of records varies. How can I achieve that task by having a nice report in Word with either 17 records or 100?

Michel,
Create a mailmerge template with 2 (or 3?) fields and make them in whatever layout you want. ie:
#Define MYDBC fullpath("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()+'mytemplate.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
Alternatively (I think this one easier for you:) create an HTML file and open that in word.
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