Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Error when using VBScript arrays

23 views
Skip to first unread message

Chris Harrington

unread,
Apr 1, 2004, 10:14:43 PM4/1/04
to
I am automating PowerPoint from WSF using VBScript. Everything is fine,
except when I try to call AddPolyline, passing an array of points. I get
the error "the specified value is out of range". I assume that it is not
getting the type of array it needs (safearray?). Is there any way to handle
this in VBScript? Also, I get the same error if I try JScript.

Someone suggested to do
triArray(0, 0) = CSng(25)
but that didn't change things.


....

Dim triArray(3,1)

triArray(0, 0) = 25
triArray(0, 1) = 100
triArray(1, 0) = 100
triArray(1, 1) = 150
triArray(2, 0) = 150
triArray(2, 1) = 50
triArray(3, 0) = 25
triArray(3, 1) = 100

slide1.AddPolyline triArray

....


Michael Harris \(MVP\)

unread,
Apr 2, 2004, 12:23:21 AM4/2/04
to
Chris Harrington wrote:
> I am automating PowerPoint from WSF using VBScript. Everything is
> fine, except when I try to call AddPolyline, passing an array of
> points. I get the error "the specified value is out of range". I
> assume that it is not getting the type of array it needs
> (safearray?). Is there any way to handle this in VBScript? Also, I
> get the same error if I try JScript.
>
> Someone suggested to do
> triArray(0, 0) = CSng(25)
> but that didn't change things.
>


The AddPolyline method (according to the docs) wants a 2D array of type
Single. Script clients can only create arrays of variants. Even if the
variant subtype is Single, it's not the same thing. A soultion is to write
a COM helper that could convert a 2D array of variant singles to a 2D array
of singles.

>
> ....
>
> Dim triArray(3,1)
>
> triArray(0, 0) = 25
> triArray(0, 1) = 100
> triArray(1, 0) = 100
> triArray(1, 1) = 150
> triArray(2, 0) = 150
> triArray(2, 1) = 50
> triArray(3, 0) = 25
> triArray(3, 1) = 100
>
> slide1.AddPolyline triArray
>
> ....

--
Michael Harris
Microsoft.MVP.Scripting
Sammamish WA US

Chris Harrington

unread,
Apr 3, 2004, 11:43:12 PM4/3/04
to
Thanks Michael. I'll give that a try.

"Michael Harris (MVP)" <mikhar at mvps dot org> wrote in message
news:%236uOeKH...@TK2MSFTNGP10.phx.gbl...

0 new messages