LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Reproducable Hard Crash in Excel 2003 (and earlier versions) with the following VBA code.

Hi,

I have a problem in some VBA code that causes a hard crash in Excel 2000 and
2003 (haven't tried Excel XP but I would assume the same result).
Fortunately I managed to reproduce the problem in a simple workbook, and the
code is that small that I can duplicate it here.

In a new workbook, add the following:


ThisWorkBook

Public Sub EntryPoint()

Dim data() As MY_DATA_TYPE

ReDim data(0)
data(0).val1 = "Test"
data(0).val2 = "Test 2"

MethodA data

End Sub

Private Sub MethodA(ByRef data() As MY_DATA_TYPE)

Dim form As UserForm1
Set form = New UserForm1
form.Test = data

End Sub


Module1

Public Type MY_DATA_TYPE
val1 As String
val2 As String
End Type


UserForm1

Private m_data() As MY_DATA_TYPE

Public Property Let Test(ByRef newValue() As MY_DATA_TYPE)
m_data = newValue
End Property

The code will crash when setting the Test property of UserForm1

This only seems to occur in this particular configuration of code. I can
pass the dyamic array through a number of methods without issue, but when I
assign the UserForm property is when it fails. It will also work fine if I
short circuit MethodB and set the UserForm property directly from the
EntryPoint method. Yet another way to get it to work is to make the dynamic
array a module level variable in ThisWorkBook and thus not have to pass it
between methods in ThisWorkbook.

I do have a work around so am not being held up by this, but I would be
appreciative if someone from Microsoft (or otherwise) could confirm this
behavior and advise whether it is a bug or known limitation. I couldn't find
anything in the KB about it.

Kind Regards,
Wayne.



 
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
List function in earlier Excel versions John_Carty Excel Discussion (Misc queries) 4 November 4th 05 08:48 AM
2003 compatibility with earlier versions George Applegate Setting up and Configuration of Excel 0 November 2nd 05 12:31 PM
2003 compatibility with earlier versions George Applegate Excel Worksheet Functions 0 November 2nd 05 12:29 PM
2003 compatibility with earlier versions George Applegate Setting up and Configuration of Excel 0 November 2nd 05 12:29 PM
2003 compatibility with earlier versions George Applegate Excel Discussion (Misc queries) 0 November 2nd 05 12:27 PM


All times are GMT +1. The time now is 05:08 AM.

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

About Us

"It's about Microsoft Excel"