Link to home
Start Free TrialLog in
Avatar of arieldri
arieldri

asked on

how to view a Word document with all the graphics inside in my delphi form?

i tried RTF but i cant see the pictures or the arrows i need in my text
maybe ill save word pages as JPG files, but its a lot of work to do, 200 pages.
maybe using ACTIVEX or OLE but i dont know anything about it and i would like to have a demo if possible
i must say that i want to see the word document in my delphi form even if microsoft office must be installed to do so, so maybe we use some office DLLs, OCXs or something :)

if u have a solution to do this using C# i will also be happy!!!
10x
Avatar of loop_until
loop_until

This might be one solution:

--- begin quote from MBo ---

I used RXRichEdit from RXLib because it can show pictures.
Save Word document as RTF.

uses ...richedit;

procedure TForm1.Button1Click(Sender: TObject);
var b:tbitmap;
 fr: TFormatRange;
 r: TRect;
begin
rxrichedit1.Lines.LoadFromFile('e:\wwe.rtf');
b:=tbitmap.create;
b.width:=rxrichedit1.width;
b.height:=rxrichedit1.height;
r:=rect(0,0,RXRichEdit1.Width*screen.Pixelsperinch,
                   RXRichEdit1.Height*screen.Pixelsperinch);
fr.hdc:=b.Canvas.handle;
fr.hdctarget:=b.Canvas.handle;
fr.rc:=r;
fr.rcpage:=r;
fr.chrg.cpMin:=0;
fr.chrg.cpMax:=-1;
Sendmessage(RXRichEdit1.handle,EM_FORMATRANGE,1,longint(@fr));
image1.Picture.assign(b);//just to control
b.savetofile('e:\wwe.bmp');
b.free;
end;

--- end quote ---


I'll try to find better thought.

Oh, I've got an idea, don't know if it'll work...

Just drop a TWebBrowser onto your form and call something like:

WebBrowser1.Navigate('file://C:\Documents and Settings\you\My Documents\whatever.doc');


Seems to work for me, but the computer on which you show this will have to have Office Word installed.
Have any questions, don't hesitate!

Have a nice day arieldri :-)

Or... if you don't have a too complex format, save your word document in HTML and show it the same way I've shown you above with TWebBrowser. You'll have images, text, format and it'll be compatible almost everywhere, having Word or not.

By the way, TWebBrowser is available in the Internet tab of Delphi 6 and 7 if I remember. Not sure if the one provided with D5 is okay for this purpose. What version do you use?

Avatar of arieldri

ASKER

thank you a lot loop until, ill try your option soon
i have delphi 7, see ya :)
Ok, hope it'll work for you :-))
Hi,

Try TOLEContainer component placed on a form. Open the file this way:
OLEContainer1.CreateObjectFromFile(FileName, False);
Also set:
OLEContainer1.AutoActivate := aaGetFocus;

Regards, Geo
ASKER CERTIFIED SOLUTION
Avatar of loop_until
loop_until

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Very good!!! the browser option seems good for me
the ole container is problematic bause it shows word toolbars.
thank u very much all!
Thanks for the points arieldri!
Happy it worked for you! :-)