Board index » delphi » Microsoft Word Document with out showing the Microsoft program from with in Delphi 4.0

Microsoft Word Document with out showing the Microsoft program from with in Delphi 4.0

I need some help!  I am trying to create a Microsoft Word Document
with out showing the Microsoft program from with in Delphi 4.0.  This
code works fine except that it shows the Word Program than closes.  Is
there any one out there that can hel me to do this in the OLE
Container.

AllowActiveDoc = False
AllowInPlace = False

    oleContainer.CreateObject('Word.Document',False);
    oleContainer.DoVerb(ovShow);   ? This is the line that I'am having
a problem with.

oleContainer.OleObject.Application.Selection.TypeText(oLongString);
    oleContainer.OleObject.Application.Quit;

Thanks,

George
ggall...@Custard.com

 

Re:Microsoft Word Document with out showing the Microsoft program from with in Delphi 4.0


I don't have a lot of experience with this, but if you don't want to show
the document, you can do it this way and it will be much faster as well.

// drop a word application server from the server's vcl on your form
WordApplication1.create(application); // it will not be visible by default.
WordApplication1.documents.add(emptyparam, emptyparam); // creates a new
document
wordApplication1.selection.typetext(' Whatever you want');

Obviously, it wont show up in the ole container with this technique.

hth,

Jack

:

Quote
George Gallant <doul...@hotmail.com> wrote in message

news:8dn0lg$39o9@bornews.borland.com...
Quote
> I need some help!  I am trying to create a Microsoft Word Document
> with out showing the Microsoft program from with in Delphi 4.0.  This
> code works fine except that it shows the Word Program than closes.  Is
> there any one out there that can hel me to do this in the OLE
> Container.

> AllowActiveDoc = False
> AllowInPlace = False

>     oleContainer.CreateObject('Word.Document',False);
>     oleContainer.DoVerb(ovShow);   ? This is the line that I'am having
> a problem with.

> oleContainer.OleObject.Application.Selection.TypeText(oLongString);
>     oleContainer.OleObject.Application.Quit;

> Thanks,

> George
> ggall...@Custard.com

Re:Microsoft Word Document with out showing the Microsoft program from with in Delphi 4.0


Hi George,

You're probably better off not using an OLE container (unless you really
need to), but use an OLE/COM connection to Word.

Something like this:

Var oWord :OleVariant ;

oWord := CreateOleObject('Word.Application');
Try
    oWord.Documents.Add ;
    oWord.ActiveDocument.SaveAs('MyNewDoc.Doc');
Finally
    oWord.Quit(0);
    oWord := Unassigned ;
End;

If you want to show Word then you can use:  oWord.Visible := True ;

-Steve-

Quote
"George Gallant" <doul...@hotmail.com> wrote in message

news:8dn0lg$39o9@bornews.borland.com...
I need some help!  I am trying to create a Microsoft Word Document
with out showing the Microsoft program from with in Delphi 4.0.  This
code works fine except that it shows the Word Program than closes.  Is
there any one out there that can hel me to do this in the OLE
Container.

AllowActiveDoc = False
AllowInPlace = False

    oleContainer.CreateObject('Word.Document',False);
    oleContainer.DoVerb(ovShow);   ? This is the line that I'am having
a problem with.

oleContainer.OleObject.Application.Selection.TypeText(oLongString);
    oleContainer.OleObject.Application.Quit;

Thanks,

George
ggall...@Custard.com

Other Threads