Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-17-2013, 01:39 PM
macropod's Avatar
macropod macropod is offline Macro to save to a single PDF Windows 7 32bit Macro to save to a single PDF Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default


Try:
Code:
Private Sub CommandButton1_Click()
Dim wkSht As Worksheet, Ctrl As Control, i As Long, ArrShts()
ReDim Preserve ArrShts(0)
For Each Ctrl In Me.Controls
  With Ctrl
    If .Name Like "CheckBox#*" Then
      If .Value = True Then
        ReDim Preserve ArrShts(i)
        ArrShts(i) = .Caption
        i = i + 1
      End If
    End If
  End With
Next
If ArrShts(0) = 0 Then GoTo NoPrint
With ActiveWorkbook
  Set wkSht = .ActiveSheet
  .Sheets(ArrShts).Select
  Application.Dialogs(xlDialogPrint).Show Arg1:=1, Arg4:=1, Arg5:=False, Arg6:=True, Arg7:=1
  wkSht.Activate
End With
NoPrint:
Unload UserForm1
End Sub
 
Private Sub UserForm_Initialize()
Dim Ctrl As Control, i As Long, ArrShts()
ArrShts() = Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", _
  "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", _
  "Jan (2)", "Feb (2)", "Mar (2)", "Apr (2)", "May (2)", "Jun (2)", _
  "Jul (2)", "Aug (2)", "Sep (2)", "Oct (2)", "Nov (2)", "Dec (2)")
  For Each Ctrl In Me.Controls
    With Ctrl
      If .Name Like "CheckBox#*" Then
        .Caption = ArrShts(i)
        i = i + 1
      End If
    End With
  Next
End Sub
Note: I couldn't help fiddling with your UserForm_Initialize sub a bit more ... The only change of substance is:
If ArrShts(0) = 0 Then GoTo NoPrint
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to save to a single PDF Macro to save as pdf with ability to choose save as folder rvessio Word VBA 4 07-25-2016 12:37 PM
Change single character in PPT to another font macro rtwwpad PowerPoint 1 01-19-2013 05:08 PM
Macro to save to a single PDF Macro to save as PDF but with a different name shabbaranks Word VBA 2 05-20-2011 01:02 AM
Macro to Save Help clarkson001 Word 0 02-14-2011 06:41 AM
Macro Won't Save lou0915 Word VBA 2 10-17-2009 08:13 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:44 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft