Solved

View a Word document in Delphi application

Posted on 2000-03-12
11
433 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
  • 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
 

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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
PDF library for Delphi 2 89
TVirtualStringTree  search using TEdit 7 81
Magic Software info 18 103
How to debug For loops? 3 34
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video discusses moving either the default database or any database to a new volume.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

705 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now