Twinword 4.0

(c)1998 CreativeSoftwareTechnik, R. Vysata

Twinword will help you to put the Data's from your Delphi-App into MS Word 8. Work with Twinword and the easy functions and property to get nice letters, reports and more. Add Images and Wordart to the Document and Insert Tables directly to Word 8. Now also includes MergeMail with Documents.

This Components is free for private use, for Commercial or Sourcecode you will pay $ 30.
Note: There are no warrantys to this component.
For Help and Questions call the author: r.vysata@magnet.at

methodes

propertys


Methodes

constructor create(aOwner: TComponent)
destructor destroy
procedure startword
procedure adddocument
procedure OpenDoc(docname: string)
procedure SaveDoc(Docname: string)
procedure PrintWordDoc(printername: string; howmuch: integer)
procedure addtexttodoc(value: String; linesbefore: integer)
procedure addmultitexttodoc(value: TStringlist; linesbefore: integer)
procedure addblanklines(value: integer)
procedure addpagebreak
procedure addtabletodoc(wordtable: TStringlist; wordstyle: integer)
function setVariables(VarName: string; VarValue: String; Nr: integer): Integer
procedure emptyvariables
procedure addvartodoc
procedure addwordarttodoc(text, fontname: string; size, style: integer)
procedure addimagetodoc(value: string)
procedure addmergedoc(value: string)
procedure addmergefieldtodoc(value: string)
procedure addmergedocspecial(docfile, sqlstr, conststr, sourcefile: string)
procedure executethemergedoc

back


Propertys

property WordNew
property Headline
property Footline
property Font
property TextAlign

back


procedure startword

this is the first procedure you must call. with this you will start Winword and get a connetcion within the OLE. if the property WORDNEW is true, the procedure try to open a new ession on each call, if false, it's try to get a connetction to Word, if it's open, first.

back


procedure adddocument

if word is ready, you can add a new, blank document to word. After you can put text or Images in this documetn or insert tables.

back


procedure OpenDoc(docname: string)

if word is ready you can open also an document. Your application must check for the extension of the doc ('.doc, *.rtf, *.txt,..) because i don't know what options you've installed your Word.

p.E.: Winword1.opendoc('c:\test.doc');

back


procedure SaveDoc(Docname: string)

with this you will save an Document, you've opend or created before.

p.E: Winword1.SaveDoc('C:\savedoc.doc');

back


procedure PrintWordDoc(printername: string; howmuch: integer)

print out the Active Document. Set the Printername, if it's not the default printer and tell word, how much copies you like.

p.E: PrintWordDoc('Epson 800', 3);

back


procedure addtexttodoc(value: String; linesbefore: integer)

add some text or files (*.doc, *.txt, *.rtf,...) to the documetn, you've opened or created before and tell word, how much blank lines you need before.

if the value is not a file (Twinword check it) the value is only a simple text.

p.E: Winword1.addtexttodoc('Hallo Word', 2) or
Winword1.addtexttodoc('C:\happy.doc', 1);

back


procedure addmultitexttodoc(value: TStringlist; linesbefore: integer)

add more then one lines of text or blank lines to the document and tell word, how much blank lines you nedd before. The value is a Stringlist, wich contains a line in Word for each String.

p.E: text := Tstringlist.create;
text.ad('Name');
text.add('Prename');
text.add(''); (it's a blank line in the document)
text.add('Street');
Winword1.addmultitexttodoc(text, 3);
text.free;

back


procedure addblanklines(value: integer)

call this to add some blank lines in the document, if you need

p.E: Winword1.AddBlanklines(5);

back


procedure addpagebreak

insert a hard page break in the Document

p.E. Winword1.addpagebreak;

back


procedure addtabletodoc(wordtable: TStringlist; wordstyle: integer)

insert a table in the Document. The Contents of the table will placed in the Stringlist
Each String in the Stringlist contains the Datas for one Row in the table, as Seperator you will put the ';' in the sting.

p.E: TableStringlist.Add('Name;Prename;Street;State;Phone);
TableStringlist.Add('Bill;Gates;road 66;California;001332');
this will add a table with 2 row and 5 Cells.

the Style as integer set the Format of the table, it must between 0 and 39. The Style will be from 3d to simple Borders. Have a Try.

p.E: Winword1.addtabletodoc(Tablestringlist, 20);

back


function setVariables(VarName: string; VarValue: String; Nr: integer): Integer

Set the Doc-Variables for the word-Document. Twinword will handle up to 20 variables for the document.
You can work with Docvariables in a document like fields. Ask for the state of a variable or insert somethink if the variable is right. Have a look to the Word-help before ! Before Print or Save a Document you have to call the procedure
AddVarToDoc.
the 'Nr' is 0 for the first and 19 for the last variable.

p.E: Winword1.setvariables('Name', 'Gate', 1);

the return of the function is:
0 = more then 20 variables!
1 = no Name of the Variable found (varname)
2 = no Value of the variable found (VarValue)
3 = OK

back


procedure emptyvariables

clear the Doc-Variables in the Component for prepare a new Document.

p.E. Winword1.emptyvariables;

back


procedure addvartodoc

if you finished your Document it's important to refresh the variables of the Document. For this call:

p.E: Winword1.addvartodoc;

back


procedure addwordarttodoc(text, fontname: string; size, style: integer)

Add a WordArt to the Document. Choose on of the 30 different Styles of the Wordart.
Important: the function WordArt of Word 8 works like a Overlay-Bitmap. It means, that's possible that the Wordart is show'n over the text from the document. If this, add some blank lines after the text.

p.E: Winword1.addwordarttodoc('This is Art', 'Courier New', 30, 11);

back


procedure addimagetodoc(value: string)

Insert a Image (Clipart) to the Document. The Image must be conform with the Word-Importfilters(normally *.bmp, *.wmf, *.jpg). But have a look to your Word-Setup options.

p.E: Winword1.addimagetodoc('C:\Clips\moon.wmf');

back


procedure addmergedoc(value: string)

Open a MailMerge-Document in Word, you've been created directly in Word. This is the simple Version of the Mailmerge-Functions in Twinword. Before use this procedure be shure, that the datasource is exists and the user can us it.
To execute the MailMerge you must call the procedure
executethemergedoc!.

p.E: Winword1.addmergedoc('C:\word\themerge.doc');

back


procedure addmergefieldtodoc(value: string)

call this procedure, if you've opened a MailMerge-Document before and you will add some new Mergefields.

p.E: Winword1.Addmergefield('Customer');

back


procedure addmergedocspecial(docfile, sqlstr, conststr, sourcefile: string)

This procedure is only for use Mailmerge with the ODBC-Datasource. Important: This procedure will be only for Useres, they know to work with the ODBC. Call the procedure Executethemergedoc after you finished the Document

Open a MailMerge-Document to use a ODBC-Datasource like an SQL-Server,...
Docfile: the path and Name of the Document
sqlstr: Put a SQL-String to the MailMerge. like 'SELECT * FROM CUSTOMERS....
conststr: the Constraints of the ODBC. Very difficult to use

p.E.: 'MS Access 97-Datenbank;DBQ=H:\MSOffice\office\Beispiel\NORDWIND.MDB;DriverId=25;FIL=MS Access;MaxBufferSize=512;PageTimeout=5;'

sourcefile: the path and name of the Database

back


procedure executethemergedoc

After you finished your MailMerge-Document call this procedure to execute the MailMerge and get the ready Documents.

p.E: Winword1.executethemergedoc

back


property WordNew

If it's true, Twinword will start every time a new Session of Word8. If false, Twinword try to get a Connection to an existing Word-Session before.
Important: If Wordnew is false and you call Startword, you get an Error if Word is'nt ready. This Error is only while Delphi is running !

back


property Headline
property Footline

These two propertys are optional for creating a new Document. If the Value <> '' then Word will insert a Headline / Footline in the new Document. If the Value is an existing Path to a Document (*.doc, *.rtf,...) then Twinword will inside the file, if it's only a String, it's put this String to the Headline/Footline.

back


property Font

The property of the Font-Stlye for the Text in the Document. Change the styles (Size, Name,..) if you want the Text to place in the Document in another stlye.

back


property TextAlign

To Change the Align of the Text (wleft, wcenter, wright or wjustify);

back


©1998 CreativeSoftwareTechnik, R. Vysata
16.10.1998