Board index » delphi » Word97 open and open Document

Word97 open and open Document

I'm working with Delphi 4.0 and can not open any file in word97.
I'm opening the wordt application with the lines below;

uses ComObj, ActiveX, Word_TLB;

var
    Word: _Application;
    Unknown: IUnknown;
    Result: HResult
begin
    Result := GetActiveObject(CLASS_Application_,nil, Unknown);
    if (Result = MK_E_UNAVALIBLE) then
    Word := CoApplication_.Create
else begin
    OleCheck(Result);
    OleCheck(Unknown. QueryInterface(_Application, Word));
end;
    Word.Visible := True;

Wat do I have to do know to open a specific document in word.

I hope you can help me,

Marcel Kr?ner

 

Re:Word97 open and open Document


<<Marcel Kroner:
Wat do I have to do know to open a specific document in word.

Quote

var
  FileName: OleVariant;
begin
  FileName := 'C:\My Documents\The file I want to open.doc';
  Word.Documents.Open(FileName, EmptyParam, EmptyParam,
         EmptyParam, EmptyParam, EmptyParam, EmptyParam,
         EmptyParam, EmptyParam, EmptyParam);

You can find this and other Word tips at
http://www.djpate.freeserve.co.uk/Automation.htm

--
Deborah Pate

Re:Word97 open and open Document


Hallo,

I Did try the lines below but I get a error every time I run the program
EAccess violation
this is what I did;
var
Word: _Application; {Whitout Word.Documents das not work}
FileName:OleVariant;
begin
FileName :='\Butzelaar\Brieven\Standaardbrief';
Word.Documents.Open(FileName, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam);
end;

I'm used to work whit Delphi 3.0 where I did this;

var
MsWord:Variant;
begin
try
MsWord := CreateOleObject('Word.Basic');
except
ShowMessage ('Kan Word niet starten');
exit;
end;
MsWord.AppShow;
MsWord.FileOpen ('\Butzelaar\Brieven\Standaardbrief');
end;

It worked fine but now I do not now what to do anymore.

Sorry, Sorry,

Marcel Kr?ner

Deborah Pate <d.p...@cableinet.co.not-this-bit.uk> schreef in berichtnieuws
38c24a4a@dnews...

Quote
> <<Marcel Kroner:
> Wat do I have to do know to open a specific document in word.

> var
>   FileName: OleVariant;
> begin
>   FileName := 'C:\My Documents\The file I want to open.doc';
>   Word.Documents.Open(FileName, EmptyParam, EmptyParam,
>          EmptyParam, EmptyParam, EmptyParam, EmptyParam,
>          EmptyParam, EmptyParam, EmptyParam);

> You can find this and other Word tips at
> http://www.djpate.freeserve.co.uk/Automation.htm

> --
> Deborah Pate

Re:Word97 open and open Document


<<Marcel Kroner:
I Did try the lines below but I get a error every time I run
the program EAccess violation

Quote

If I've understood your message properly, you're trying to
open a document now without having opened Word - or at
least, without having access to the _Application variable
you opened Word with. You must use the code you put in
your first message, followed by the Word.Documents.Open
call (while the Word variable is still in scope!).

--
Deborah Pate

Other Threads