Re: Forms, Word and Document Variables

From: John Brown <johnbrown105_at_hotmail.com>
Date: 25 Jul 2002 18:20:36 -0700
Message-ID: <ee1f9e62.0207251720.7c823fbf_at_posting.google.com>


markg_at_mymail.co.uk (Mark) wrote in message news:<ddb31653.0207160125.503db09e_at_posting.google.com>...
> Hi,
>
> I have an application which is trying to read a document variable from
> Word.
> ...
> The VBA equivalent for writing and reading the document variables are
> as follows:
>
> ActiveDocument.Variables.Add Name:="MyVar", Value:="12"
> > ActiveDocument.Variables("MyVar").Value
>

...
> message('Reading Document Variable');
>
> -- Read the document variable and display on Forms message line
> args:=OLE2.CREATE_ARGLIST;
> OLE2.ADD_ARG(args, 'MyVar');
> var:=OLE2.INVOKE_CHAR(MyDocument,'Variables',args);
> message(var);

I think you should have:
var := ole2.get_char_property(MyDocument,'Variables', args) instead of var:=OLE2.INVOKE_CHAR(MyDocument,'Variables',args);

Value is a property, not a method.
Your VBA code as written would fail at
ActiveDocument.Variables("MyVar").Value for the same reason. You would need something like:

dim x as integer
x = ActiveDocument.Variables("MyVar").Value Received on Fri Jul 26 2002 - 03:20:36 CEST

Original text of this message