Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Public array

I have an two event handler procedures that uses a public array
declared in a different module. The public array is undimensioned. In
one of the procedures it is dimensioned and given values. The other
procedure uses this array of values set by the first procedure. I need
to use the array in a procedure on a custom add in. When I try to call
values from this array, I get an error . The editor indicates that the
array is empty. Is there a way I can pass the dimensioned array with
values to the procedure in the add in?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Public array

This isn't an array issue, it is a scope issue. Public variables are
visible within their VB project, not in other VB projects. There are two
ways around this I think. One is to set a reference to the project that has
the array in the project that wants to access it. You will first have to
change the name of at least one of the VB projects (from VBAProject) so they
are different.

The other way is to create a function in the project that has the array that
passes the array to the function's caller. And then use the Run method in
the other project to call that function and receive the array back:

In project with array:

Public Arr() As String

Sub SetArray()
ReDim Arr(1 To 2)
Arr(1) = 10
Arr(2) = 20
End Sub

Function PassArray() As Variant
PassArray = Arr
End Function

In the other project:

Sub GetArray()
Dim MyArray As Variant
MyArray = Run("BookWithArray.xls!PassArray")
MsgBox MyArray(2)
End Sub



--
Jim
"bobbo" wrote in message
ups.com...
|I have an two event handler procedures that uses a public array
| declared in a different module. The public array is undimensioned. In
| one of the procedures it is dimensioned and given values. The other
| procedure uses this array of values set by the first procedure. I need
| to use the array in a procedure on a custom add in. When I try to call
| values from this array, I get an error . The editor indicates that the
| array is empty. Is there a way I can pass the dimensioned array with
| values to the procedure in the add in?
|


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
public array AD108 Excel Programming 6 August 11th 06 07:19 AM
public or global array shishi Excel Programming 2 February 6th 06 09:29 PM
public array Circe[_2_] Excel Programming 6 May 17th 05 11:45 PM
Array of Public Arrays Hari Prasadh Excel Programming 1 January 21st 05 03:42 PM
Public Array Brent McIntyre Excel Programming 5 September 23rd 03 12:53 AM


All times are GMT +1. The time now is 08:28 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"