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

arieldri
arieldri used Ask the Experts™
on
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
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
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 :-)

Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

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?

Author

Commented:
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
Yeah, geobul's way might be the quickest way altought if you want to distribute to customer, as you don't know if they'll have Word installed, you might want to save it as HTML and open it using the WebBrowser. Well, it's a matter of taste now! :-)

Author

Commented:
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! :-)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial