Quantcast
Channel: Excel IT Pro Discussions forum
Viewing all articles
Browse latest Browse all 11829

print command for multi page form excel 2010

$
0
0

hello all, I have a print module that prints my forms in landscape, what I would like to do is have one button that prints all 5 pages of my multipage form.  should I use next, or loop or case ?  I am new to user form but I need something like

multipage1.value = 0

Print form using the sub

multipage1.value = 1

Print form using the sub

multipage1.value = 2

Print form using the sub

multipage1.value = 3

Print form using the sub

multipage1.value = 4

Print form using the sub

Option Explicit
 Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, _
     ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
 Const VK_SNAPSHOT = 44
 Const VK_LMENU = 164
 Const KEYEVENTF_KEYUP = 2
 Const KEYEVENTF_EXTENDEDKEY = 1
 Sub SnapShot()
  DoEvents
     keybd_event VK_LMENU, 0, KEYEVENTF_EXTENDEDKEY, 0
     keybd_event VK_SNAPSHOT, 0, KEYEVENTF_EXTENDEDKEY, 0
     keybd_event VK_SNAPSHOT, 0, KEYEVENTF_EXTENDEDKEY + _
         KEYEVENTF_KEYUP, 0
     keybd_event VK_LMENU, 0, KEYEVENTF_EXTENDEDKEY + _
         KEYEVENTF_KEYUP, 0
     DoEvents
     Workbooks.Add
     Application.Wait Now + TimeValue("00:00:01")
     ActiveSheet.PasteSpecial Format:="Bitmap", Link:=False, _
         DisplayAsIcon:=False
     ActiveSheet.Range("A1").Select
     'added to force landscape
     ActiveSheet.PageSetup.Orientation = xlLandscape
   With ActiveSheet.PageSetup
         .PrintTitleRows = ""
         .PrintTitleColumns = ""
   End With
     ActiveSheet.PageSetup.PrintArea = ""
   With ActiveSheet.PageSetup
         .LeftHeader = ""
         .CenterHeader = ""
         .RightHeader = ""
         .LeftFooter = ""
         .CenterFooter = ""
         .RightFooter = ""
         .LeftMargin = Application.InchesToPoints(0.75)
         .RightMargin = Application.InchesToPoints(0.75)
         .TopMargin = Application.InchesToPoints(1)
         .BottomMargin = Application.InchesToPoints(1)
         .HeaderMargin = Application.InchesToPoints(0.5)
         .FooterMargin = Application.InchesToPoints(0.5)
         .PrintHeadings = False
         .PrintGridlines = False
         .PrintComments = xlPrintNoComments
         .PrintQuality = 600
         .CenterHorizontally = True
         .CenterVertically = True
         .Orientation = xlLandscape
         .Draft = False
         .PaperSize = xlPaperA4
         .FirstPageNumber = xlAutomatic
         .Order = xlDownThenOver
         .BlackAndWhite = False
         .Zoom = False
         .FitToPagesWide = 1
         .FitToPagesTall = 1
     End With
     ActiveWindow.SelectedSheets.PrintOut Copies:=1
     ActiveWorkbook.Close False
End Sub
Thanks

 


Viewing all articles
Browse latest Browse all 11829

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>