View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
AB AB is offline
external usenet poster
 
Posts: 33
Default Printing form & contents

Dave,

I got it to work by creating some arrays to dump the listboxes into. It's
working great.

Thank you very, very much for the advice, direction, ideas, and scripting.

-AB

"Dave Peterson" wrote:

I don't have a guess.

You may want to post the code you used and a little info (anything special???)
about the listboxes?

AB wrote:

I'm getting a "'1004' Application-defined or object-defined error" on the
following line:
wks.Cells(2, oCol).Resize(.Object.ListCount).Value _
= .Object.List

Any ideas on what might be causing the problem? Aside from this, it's
working like a charm.

"Dave Peterson" wrote:

I have no ideas what those categories are, but maybe this'll get you started:

Option Explicit
Private Sub CommandButton1_Click()
Dim ctrl As Control
Dim wks As Worksheet
Dim oCol As Long

Set wks = Worksheets.Add

oCol = 0
For Each ctrl In Me.Controls
If TypeOf ctrl Is MSForms.ListBox Then
oCol = oCol + 1
With ctrl
wks.Cells(2, oCol).Resize(.Object.ListCount).Value _
= .Object.List
End With
End If
Next ctrl

Me.Hide

With wks
.UsedRange.Columns.AutoFit
.PrintOut preview:=True
Application.DisplayAlerts = False
.Delete
Application.DisplayAlerts = True
End With

Unload Me

End Sub

AB wrote:

So how would I go about this? At the moment, I've got a massive
UserForm1_Initialize script that goes through and collects all the
information that needs to be on the form. I'd prefer to create a new sub to
run on the print button. I want it to create a new sheet with columns A, B,
C, and D each having a header cell with the category they represent, then
their contents below. Then, I'd like to print the worksheet and delete it
from the workbook.

I'm not sure where to start. Can someone please help get me started?

"Dave Peterson" wrote:

How about just dumping the lists to a new worksheet and printing that.



AB wrote:

To clarify, I have already tried UserForm1.PrintForm, which does a fine job
of printing the form.

However, on the form I have three list boxes with order numbers that have
been flagged for review. The printing doesn't let you see what is scrolled
down the listbox.

More than anything, I'd like to print the information dumped into the
listbox and a column header. There are other items on the form that would be
nice to have, but not critical.

"AB" wrote:

I've created a form that populates some fields with flagged items from my
spread sheet.

How do I get my print button to print the items listed on the form?

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson