I'll try this again. Everything works fine as i stated before but where the problem starts is if you select multiple records in the listbox to print envelopes for. The code will see all the selections made, (I verified this with the debugger) but when it actually comes time to print the envelopes, it will only print the last record selected in the listbox. "Last" meaning the last alphabetically. I'm not sure on this one. Does the code need to print to the oDoc for each selection found? If so, that could turn into a nightmarish issue. ive included the code for the print function. Can someone take a look and see if they can figure out an answer to this issue? it has to print all selections, not just the last one.
Private Sub cmbtnPrint_Click()
Dim otable As Range, r As Long, c As Long, sAddr As String, rAddr As String
Dim oWord As Word.Application, oDoc As Word.Document
With Me.ListBox1
If .ListIndex = -1 Then Exit Sub '''/// no selection made
''///check if the current value is selected
For iX = 1 To .ListCount
''///check if the current value is selected
If .Selected(iX - 1) = True Then
sAddr = .List(iX - 1, 1) & " " & .List(iX - 1, 0) & vbCr & .List(iX - 1, 2) & vbCr & .List(iX - 1, 3) & " " & .List(iX - 1, 4) & " " & .List(iX - 1, 5)
rAddr = Sheets("Data").Range("A1").Value & vbCr & Sheets("Data").Range("A2").Value & vbCr & Sheets("Data").Range("A3").Value & vbCr & Sheets("Data").Range("A4").Value & ", " & Sheets("Data").Range("A5").Value & ", " & Sheets("Data").Range("A6").Value
End If
Next iX
End With
Set oWord = CreateObject("Word.Application")
Set oDoc = oWord.Documents.Add
If Me.ckbxAbsenteeBallot = True Then
'If Me.ckbxAbsenteeBallot Then
oDoc.Envelope.PrintOut , rAddr, , , sAddr, , , , "Size 12"
Else:
If Me.ckbxAbsenteeEnvelope = True Then
oDoc.Envelope.PrintOut , sAddr, , , rAddr, , , , "Size 14"
End If
End If
''/// pause macro for 5 seconds(approx)
Application.Wait (Now + TimeValue("0:00:10"))
oWord.Quit False
End Sub
Display More
Thanks again for any and all help!!