Board index » delphi » Automation with word_tlb

Automation with word_tlb

Hi All

I've written Word automation objects using word_tlb.pas and am having
problems with the following code on some machines only.  All of the machines
I've tested on have the same version of Windows 98, Office 2000 and Word.
Here's the code
-----------------------------------------------------------------------
function TWordEventSink.Invoke( DispID : Integer; const IID: TGUID; LocaleID
:Integer; Flags : Word; var Params ; VarResult,ExcepInfo, ArgErr : Pointer )
: HRESULT;

var
    aParams : TDispParams absolute Params;

begin
    if( DispID = 6 ) then
        Self.BeforeCloseDoc( IUnknown( aParams.rgvarg^[0].unkVal ) as
_Document, aParams.rgvarg^[1].pbool^ );
end;

procedure TWordEventSink.BeforeCloseDoc( const aDocument : WordDocument; var
Cancel : WordBool );
var
    aCancel : Boolean;
    aDocName : OleVariant;
begin
    if( Assigned( FonCloseDocument ) then
    begin
        aCancel := Cancel;
        aDocName := aDocument.Name;
        FOnCloseDocument( FOwner,

aDocument.Get_HTMLProject.Get_HTMLProjectItems.Item( aDocName ).Text,
                                       aCancel );
    end;
end;
-------------------------------------------------------
An "OLEException : Parameter is Incorrect" exception is thrown when trying
to resolve aDocument.Get_HTMLProject but as I say this only happens on some
machines.  I'm assuming I haven't got something installed but I can't work
out what.  Has anyone got an idea what the problem may be?

Chris

 

Re:Automation with word_tlb


hi,

as your problems focus on html stuff I would suspect the windows scripting
host, which usually comes with IE. I would check the IE and WShost versions?

--
regards,

Peter.van.Ooi...@Gekko-Software.nl
http://www.gekko-software.nl/software.htm

Quote
"Chris Dobson" <do...@freenet.co.uk> wrote in message

news:3cbf407d_1@dnews...
Quote
> Hi All

> I've written Word automation objects using word_tlb.pas and am having
> problems with the following code on some machines only.  All of the
machines
> I've tested on have the same version of Windows 98, Office 2000 and Word.
> Here's the code
> -----------------------------------------------------------------------
> function TWordEventSink.Invoke( DispID : Integer; const IID: TGUID;
LocaleID
> :Integer; Flags : Word; var Params ; VarResult,ExcepInfo, ArgErr :
Pointer )
> : HRESULT;

> var
>     aParams : TDispParams absolute Params;

> begin
>     if( DispID = 6 ) then
>         Self.BeforeCloseDoc( IUnknown( aParams.rgvarg^[0].unkVal ) as
> _Document, aParams.rgvarg^[1].pbool^ );
> end;

> procedure TWordEventSink.BeforeCloseDoc( const aDocument : WordDocument;
var
> Cancel : WordBool );
> var
>     aCancel : Boolean;
>     aDocName : OleVariant;
> begin
>     if( Assigned( FonCloseDocument ) then
>     begin
>         aCancel := Cancel;
>         aDocName := aDocument.Name;
>         FOnCloseDocument( FOwner,

> aDocument.Get_HTMLProject.Get_HTMLProjectItems.Item( aDocName ).Text,
>                                        aCancel );
>     end;
> end;
> -------------------------------------------------------
> An "OLEException : Parameter is Incorrect" exception is thrown when trying
> to resolve aDocument.Get_HTMLProject but as I say this only happens on
some
> machines.  I'm assuming I haven't got something installed but I can't work
> out what.  Has anyone got an idea what the problem may be?

> Chris

Other Threads