View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Renate[_2_] Renate[_2_] is offline
external usenet poster
 
Posts: 3
Default Using Transpose from within VBA with 256 array

Hi all,

I'm trying to automate Excel from within Word. In my code I have a two
dimensional array with over 300 elements. The Transpose command doesn't seem
to work in this situation.
It works perfectly for arrays with up to 256 elements but I can't get it to
work for my code.

I made an example to show where I am talking about, this code doesn't put
anything in the Excel sheet.

-----------------------------------------------------------------------------------
Dim arrData() As String
Dim i As Long
Dim j As Long
Dim oXlApp As Excel.Application
Dim oXlBoek As Excel.Workbook

ReDim arrData(1, 257)

For i = 1 To 257

j = i - 1
arrData(0, j) = j
arrData(1, j) = j

Next i

On Error Resume Next
Set oXlApp = GetObject(Class:="Excel.Application")
If Err.Number < 0 Then
Err.Clear
Set oXlApp = CreateObject(Class:="Excel.Application")
End If

oXlApp.Visible = True
Set oXlBoek = oXlApp.Workbooks.Add
arrData = oXlApp.Application.Transpose(arrData)
j = UBound(arrData, 2)
oXlBoek.Sheets(1).Cells(1, 1).Resize(2, j).Value = arrData

Set oXlBoek = Nothing
Set oXlApp = Nothing

-----------------------------------------------------------------------------------

If I redimension the array to 256 elements, this code works fine, but I need
it to work for a larger array. Can anyone please give me a suggestion how I
can solve this?

TIA,
Renate