Thanks for persisting with this.
I've changed things to try to copy a similar form
in the same module, which works (sorry to change
things, but I'm trying anything!)
The similar form is named: GetUserPrintOptions.
This is the call from the standard module, and the
subsequent code to set the variables, when code
returns:
GetUserPrintOptions.Show
'get user's print options
With GetUserPrintOptions.ListBox1
If GetUserPrintOptions.ListBox1.Selected(0) = True Then
Global_PrintAllBooks_Sheets = True
End If
If GetUserPrintOptions.ListBox1.Selected(1) = True Then
Global_HideSameCols = True
End If
If GetUserPrintOptions.ListBox1.Selected(2) = True Then
Global_DoNot_HideCols = True
End If
If GetUserPrintOptions.ListBox1.Selected(3) = True Then
Global_PrintZeroPages = True
End If
If GetUserPrintOptions.ListBox1.Selected(4) = True Then
Global_DoNot_PrintZeroPages = True
End If
If GetUserPrintOptions.ListBox1.Selected(5) = True Then
Global_PrintBlankPages = True
End If
If GetUserPrintOptions.ListBox1.Selected(6) = True Then
Global_DoNot_PrintBlankPages = True
End If
End With
Unload GetUserPrintOptions
This is the only code behind that form:
Option Explicit
Private Sub CancelButton_Click()
Unload GetUserPrintOptions
End Sub
Private Sub OKButton_Click()
Me.Hide
End Sub
Private Sub UserForm_Initialize()
'Fill the ListBox
With GetUserPrintOptions.ListBox1
.RowSource = ""
.AddItem "You want to print EVERY Worksheet in EVERY chosen Workbook"
.AddItem "You want to hide a Column(s) before printing, and you want to"
& vbNewLine _
& "hide the same column(s) in every workbook and every
worksheet" & vbNewLine _
& "you wish to print"
.AddItem "You don't wish to hide any columns, in any workbook or
worksheet"
.AddItem "You want to print EVERY page...including pages that total
'0.00'" & vbNewLine _
& "in every workbook and every worksheet you wish to print"
.AddItem "You don't wish to print any pages that total '0.00'" &
vbNewLine & _
"in any workbook or sheet"
.AddItem "You want to print EVERY page...including pages with no totals"
& vbNewLine _
& "in every workbook and every worksheet you wish to print"
.AddItem "You don't wish to print any pages with no totals in any" &
vbNewLine & _
"workbook or sheet"
End With
End Sub
Taking this as a working example, I have amended the originally
posted code so that later in the same routine (from the standard module):
GetUserWkbkPrintOptions.Show
'get user's workbook-specific print options
With GetUserWkbkPrintOptions.ListBox1
If GetUserPrintOptions.ListBox1.Selected(0) = True Then
Wkbk_HideSameCols = True
End If
If GetUserPrintOptions.ListBox1.Selected(1) = True Then
Wkbk_HideDifferentCols = True
End If
If GetUserPrintOptions.ListBox1.Selected(2) = True Then
Wkbk_DoNotHideCols = True
End If
If GetUserPrintOptions.ListBox1.Selected(3) = True Then
Wkbk_PrintAllZeroPages = True
End If
If GetUserPrintOptions.ListBox1.Selected(4) = True Then
Wkbk_PrintSomeZeroPages = True
End If
If GetUserPrintOptions.ListBox1.Selected(5) = True Then
Wkbk_DoNotPrintZeroPages = True
End If
If GetUserPrintOptions.ListBox1.Selected(6) = True Then
Wkbk_PrintAllBlankPages = True
End If
If GetUserPrintOptions.ListBox1.Selected(7) = True Then
Wkbk_PrintSomeBlankPages = True
End If
If GetUserPrintOptions.ListBox1.Selected(8) = True Then
Wkbk_DoNotPrintBlankPages = True
End If
End With
Unload GetUserWkbkPrintOptions
and then the only code behind this form is :
Option Explicit
Private Sub CancelButton_Click()
Unload GetUserWkbkPrintOptions
End Sub
Private Sub UserForm_Initialize()
'Fill the ListBox
With GetUserWkbkPrintOptions.ListBox1
.RowSource = ""
.AddItem "You want to hide the same Columns in every Worksheet in this
Workbook"
.AddItem "You want to hide different Columns in different Worksheets in
this Workbook"
.AddItem "You don't want to hide any Columns in this Workbook before
printing"
.AddItem "You want to print '0.00' pages in every Worksheet in this
Workbook"
.AddItem "You want to print '0.00' in some Worksheets in this Workbook"
.AddItem "You don't want to print any '0.00' pages in this Workbook"
.AddItem "You want to print blank pages in every Worksheet in this
Workbook"
.AddItem "You want to print blank pages in some Worksheets in this
Workbook"
.AddItem "You don't want to print any blank pages in this Workbook"
End With
End Sub
Private Sub OKButton_Click()
Me.Hide
End Sub
Now I thought I had followed the earlier example faithfully, and that all
would work.........not so.
All appears to work correctly, until the routine returns to the standard
module. When the line " If GetUserPrintOptions.ListBox1.Selected(0) = True
Then"
is stepped through, I'm immediately sent to the line
Private Sub UserForm_Initialize() in the code behind the form
GetUserPrintOptions
......???
All variables are declared in the standard module, at the start of the
routine.
Hope it is ok to have snipped some of this overlong post.
Regards.