D
Dave
Hi,
I'm using a doc with a table as a source to populate a
listbox on a userform.
The goal is for the user to choose a lastname from a
list, and get the corresponding address info into
variables for insertion into the doc. The table has 400+
rows and 3 columns. Col1 has Lastname, Col2 has 1st
address line, Col3 has the complete address resembling a
mailing label with CRs in it.
The last variable isn't getting set with the full
address. I tried changing the type to variant from string,
but it didn't help. The code is listed below.
Thanks in advance for any help!
Private Sub cmdCancel_Click()
frmGetAdd.Hide
End Sub
Private Sub cmdOK_Click()
Dim ListReturn As Integer
ListReturn = frmGetAdd.lstMDNames.ListIndex
ListReturn = ListReturn + 1
frmGetAdd.Hide
vAddressee = arrAddBook(ListReturn, 2)
vAddress = arrAddBook(ListReturn, 3)
MsgBox ("Addressee is " & vAddressee & vbNewLine & _
"Address is " & vAddress)
End Sub
Private Sub UserForm_Initialize()
Documents.Open FileName:="C:\documed\blanks\OSC
AddBook.doc"
With ActiveDocument.Tables(1)
Dim rcount As Integer
rcount = .Rows.Count
ReDim arrAddBook(1 To rcount, 3) As Variant
For i = 1 To rcount
arrAddBook(i, 0) = .Cell(i, 0).Range.Text
arrAddBook(i, 1) = .Cell(i, 1).Range.Text
arrAddBook(i, 2) = .Cell(i, 2).Range.Text
Next i
End With
ActiveDocument.Close wdDoNotSaveChanges
With frmGetAdd.lstMDNames
For r = 1 To rcount
.AddItem arrAddBook(r, 0)
Next r
End With
End Sub
I'm using a doc with a table as a source to populate a
listbox on a userform.
The goal is for the user to choose a lastname from a
list, and get the corresponding address info into
variables for insertion into the doc. The table has 400+
rows and 3 columns. Col1 has Lastname, Col2 has 1st
address line, Col3 has the complete address resembling a
mailing label with CRs in it.
The last variable isn't getting set with the full
address. I tried changing the type to variant from string,
but it didn't help. The code is listed below.
Thanks in advance for any help!
Private Sub cmdCancel_Click()
frmGetAdd.Hide
End Sub
Private Sub cmdOK_Click()
Dim ListReturn As Integer
ListReturn = frmGetAdd.lstMDNames.ListIndex
ListReturn = ListReturn + 1
frmGetAdd.Hide
vAddressee = arrAddBook(ListReturn, 2)
vAddress = arrAddBook(ListReturn, 3)
MsgBox ("Addressee is " & vAddressee & vbNewLine & _
"Address is " & vAddress)
End Sub
Private Sub UserForm_Initialize()
Documents.Open FileName:="C:\documed\blanks\OSC
AddBook.doc"
With ActiveDocument.Tables(1)
Dim rcount As Integer
rcount = .Rows.Count
ReDim arrAddBook(1 To rcount, 3) As Variant
For i = 1 To rcount
arrAddBook(i, 0) = .Cell(i, 0).Range.Text
arrAddBook(i, 1) = .Cell(i, 1).Range.Text
arrAddBook(i, 2) = .Cell(i, 2).Range.Text
Next i
End With
ActiveDocument.Close wdDoNotSaveChanges
With frmGetAdd.lstMDNames
For r = 1 To rcount
.AddItem arrAddBook(r, 0)
Next r
End With
End Sub