Array Problems Continue Still

P

PAM

On 12/16/03 Doug responded to my array problems. I took
what he had, put it in my User Form and it works for a one
level array. I just CAN'T figure out how to make it
multiple arrays. Please look at code and see if anyone
can identify where the problem is. I have tried for the
last two days to make this work, but just can't get it.

code follows:

Private Sub UserForm_Initialize()
Dim sourcedoc As Document
Dim i As Integer
Dim j As Integer
Dim myitem As Range
Dim m As Long
Dim n As Long

Dim r As Integer
Dim s As Integer
Dim myitemRank As Range
Dim p As Long
Dim q As Long

Dim t As Integer
Dim u As Integer
Dim myitemOfcSym As Range
Dim v As Long
Dim w As Long

Dim x As Integer
Dim y As Integer
Dim myitemProjects As Range
Dim z As Long
Dim a As Long



Application.ScreenUpdating = False

'Open the file containing the resource details

Set sourcedoc = Documents.Open
(FileName:="c:\WINNT\Profiles\cheekp\Personal\newest
table.doc")

'Get the number of resources = number of rows in the
table less one

i = sourcedoc.Tables(1).Rows.Count - 1
'Get the number of columns in the table of resources

j = sourcedoc.Tables(1).Columns.Count

'Set the number of columns in the Listbox to match
'the number of columns in the table of client details

ListBox1.ColumnCount = j

'Define an array to be loaded with the client data

Dim MyArray() As Variant

'Load client data into MyArray

ReDim MyArray(i, j)
For n = 0 To j - 3
For m = 0 To i - 1
Set myitem = sourcedoc.Tables(1).Cell(m + 2, n +
1).Range
myitem.End = myitem.End - 1
MyArray(m, n) = myitem.Text
Next m
Next n

'Load data into ListBox1

ListBox1.List() = MyArray



r = sourcedoc.Tables(1).Rows.Count - 1
'Get the number of columns in the table of resources

s = sourcedoc.Tables(1).Columns.Count

'Set the number of columns in the Listbox to match
'the number of columns in the table of client details

ListBox2.ColumnCount = j

'Define an array to be loaded with the client data


Dim MyArrayRank() As Variant

'Load client data into MyArray

ReDim MyArrayRank(r, s)
For q = 0 To s - 3
For p = 0 To r - 1
Set myitemRank = sourcedoc.Tables(1).Cell(p + 2, q
+ 1).Range
myitemRank.End = myitemRank.End - 1
MyArrayRank(r, s) = myitemRank.Text
Next p
Next q

'Load data into ListBox1

ListBox2.List() = MyArrayRank




'Close the file containing the client details

sourcedoc.Close SaveChanges:=wdDoNotSaveChanges

End Sub


Private Sub CommandButton1_Click()

Dim i As Integer
Dim Name As String
Dim Rank As String
Dim OfcSym As String
Dim Projects As String


Name = ""
Rank = ""
OfcSym = ""
Projects = ""

For i = 1 To ListBox1.ColumnCount
ListBox1.BoundColumn = i
Name = Name & ListBox1.Value & vbCr

Next i

For r = 1 To ListBox2.ColumnCount

ListBox2.BoundColumn = j
Rank = ListBox2.Value & vbCr

Next r

'UserForm1.Hide
End Sub


Thanks in advance
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

Hi Pam,

The code that I gave you will load the three columns from your table into
three columns in a listbox. I am not sure what the purpose is of your
second listbox.

You can access the data in the various columns of the one listbox by setting
the .BoundColumn property of the listbox.

If you want to send your template to me, I will take a look at it so that I
can try and understand what you are doing.

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
P

Pam

Thanks Doug. I will send it to you.
-----Original Message-----
Hi Pam,

The code that I gave you will load the three columns from your table into
three columns in a listbox. I am not sure what the purpose is of your
second listbox.

You can access the data in the various columns of the one listbox by setting
the .BoundColumn property of the listbox.

If you want to send your template to me, I will take a look at it so that I
can try and understand what you are doing.

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP



.
 
P

PAM

Doug

I have attempted twice to send you my file. Keep getting
it back as unknown. Could I have you e-mail address to
forward file?

Thanks in advance

PAM
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

Hi Pam,

If you click reply to my message, you will see:

----- Original Message -----
From: "Doug Robbins - Word MVP - DELETE UPPERCASE CHARACTERS FROM EMAIL
ADDRESS" <[email protected]>

If you do that, you will end up with (e-mail address removed)

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top