I have created a complex macro in word reading through a standardised document.

All amounts are picked up in an array called NBs(40,10) through a select
case.

If I start the macro once again - even with another document - the old
amounts are still in the NBs() array.

I then tried a sub to clean up the array. That did even not work.

So I have top close Word completely to avoid old figures?

I have run the macro in word 2000 2003 and now in 2007 with the same bad
result.

Are there anybody who knows a way around this fault?

kind regards

Niels

RE: old amounts in an array run more than once by oldman

oldman
Sun Apr 15 16:24:02 CDT 2007

Hi,

Its unclear where your array is declared (at the procedure or modular leval
and how) - so please post some code.

To clear out an array you can do this:

Dim a1() as integer
ReDim a1(200)
a1(1) = 50

ReDim a1(200)

This creates a dynamic array. When it is 'redimed' all the previous values
are lost. In this case I used the same length.

To preserve the values use this:

ReDim preserve a1(200)

you can also redim to another length:

redim a1(25)

with, or without, preserve.

old man

"Niels" wrote:

> I have created a complex macro in word reading through a standardised document.
>
> All amounts are picked up in an array called NBs(40,10) through a select
> case.
>
> If I start the macro once again - even with another document - the old
> amounts are still in the NBs() array.
>
> I then tried a sub to clean up the array. That did even not work.
>
> So I have top close Word completely to avoid old figures?
>
> I have run the macro in word 2000 2003 and now in 2007 with the same bad
> result.
>
> Are there anybody who knows a way around this fault?
>
> kind regards
>
> Niels