1-)how I can insert new page in word document from delphi
2-)my database field longer then 255 character but dbgird show only first 255 character. why? and how I can show all characters?
I am sory for my bad English...
Claude
02-14-2001, 01:03 PM
Your question contains two unrelated topics!
Regarding adding a page to Word, Delphi Servers components will expose the Word Object model; you have to master this model. Hundreds of objects are available and these objects often have dozens of properties/methods. The following example uses the TypeText method to alter a document. It types "Hello" at the current cursor location and then inserts a page break.
var
FileName : OleVariant;
WordApplication : TWordApplication;
begin
FileName := 'c:\test.doc';
WordApplication := TWordApplication.Create(self);
WordApplication.Connect;
WordApplication.Documents.Open(Filename, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, EmptyParam);
WordApplication.ActiveDocument.ActiveWindow.
Selection.TypeText('Hello' + #12);
WordApplication.ActiveDocument.Save;
WordApplication.Disconnect;
WordApplication.Free;
end;
As you may notice, the TypeText applies to the selection object, which is a property of the ActiveWindow Object. To insert text as a specific location, you will have to navigate thru the document. I can only recommand that you read a good book about the Word Object Model (I personnaly use "Writing Word Macros" published at O'Reilly).
Regarding the second question, It is the first time I hear about a database having strings longer that 255 characters. Usually, longer strings are put in Memo fields. What database are you using? Are you sure your field is really longer than 255 characters? If so, maybe delphi truncates the string and you should consider a DbGrid replacement that supports "Memo" cells (I use DevExpress's Quantum Grid and I am very satisfied).
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.