Solved

View a Word document in Delphi application

Posted on 2000-03-12
11
452 Views
Last Modified: 2010-04-04
I whant to view a Word document in my application without opening Word. Is it possible and how to do it?

Dag
0
Comment
Question by:dikonsult
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +2
11 Comments
 
LVL 25

Expert Comment

by:Mr_Peerapol
ID: 2609422
Listening ...
0
 

Accepted Solution

by:
pellelil earned 50 total points
ID: 2609590
I doubt any has written a "word viwer" component, so that you can view the file without using word. However using OLE/COM you can ask WORD (if installed on the PC) to do the work for you.

A Quick-and-Dirty solution would be to insert a TOleContainer (found in the "Systems" note tab) into an form. Double-click the OleContaine and set it up for "Microsoft Word Documents"
0
 

Author Comment

by:dikonsult
ID: 2610371
Yes it work with a OLEcontainer and to open the file with OLEcontainer.CreateLinkToFile(filename,false)
but

do you know how to scroll the document?

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:pellelil
ID: 2611129
I have never tried it, but I guess that using COM you can ask WORD to perform the scroll.
0
 
LVL 3

Expert Comment

by:raidos
ID: 2612356
I suppose OleContainer.OleObject.Application.ActiveWindow.ActivePane.VerticalPercentScrolled := Integer; would scroll it.. for you, not sure though.

Good luck
//raidos
0
 
LVL 3

Expert Comment

by:gandalf_the_white
ID: 2613005
listening...
0
 

Author Comment

by:dikonsult
ID: 2613108
Forgive a beginner, but what do you mean with "Listening"
0
 

Author Comment

by:dikonsult
ID: 2613150
No
OleContainer.OleObject.Application.ActiveWindow.ActivePane.VerticalPercentScrolled := Integer;
did not work, getting a error message telling "Interface not supported"
0
 
LVL 3

Expert Comment

by:gandalf_the_white
ID: 2623083
listening means that i'm interested in the subject and want to be informed
if there's an answer to the topic
0
 

Author Comment

by:dikonsult
ID: 2624974
This works

     OleContainer1.CreateObjectFromFile(DataModule1.TestOrderQueryDocument.AsString,false);
     OleContainer1.DoVerb(ovShow);
     TabSheet2.SetFocus;

The TabSheet2.SetFocus; is a quick and dirty method to get rid of the Word menu since I use a TabSheet that can't be locked.

I'm not satisfied since it is a very slow method.
I would rather use
OLEcontainer1.CreateObject(Word.Document.8);
OLEcontainer1.Run;
in Form1.Create
and then open the documents directly in the OLEcontainer.

But I don't know how to open a document without using Word open dialog.
0
 

Expert Comment

by:pellelil
ID: 2626822
How about using COM ?

Var
  S, TmpS : string;
begin
  Try
    VarW := CreateOleObject('Word.Basic');
  except
    ShowMessage('Microsoft Word is not installed');
  end;
  VarW.AppShow;
  VarW.FileOpen('somefile.doc');
  ...

This will open word, however I don't know how to use COM to open it into your container, however I guess is possible (somehow)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question