lifeson
03-02-2009, 04:20 AM
Hi all
I have a userform that has 7 tabs
Tab 7 contains an imagecontrol that shows various images.
I want a method of printing the image when a user presses Ctrl & p
This identifies that page 7 is active
Private Sub MultiPage1_Change()
If MultiPage1.Value = 7 Then
Application.OnKey "^p", "PrintImage(imgFile)"
End If
End Sub
This should then call this routine
Sub PrintImage(imgFile As String)
'MsgBox "Do you want to print " & imgFile
Application.Worksheets.Add
ActiveSheet.Pictures.Insert(imgFile).Select
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = "Colours may not be as shown"
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.748031496062992)
.RightMargin = Application.InchesToPoints(0.748031496062992)
.TopMargin = Application.InchesToPoints(0.984251968503937)
.BottomMargin = Application.InchesToPoints(0.984251968503937)
.HeaderMargin = Application.InchesToPoints(0.511811023622047)
.FooterMargin = Application.InchesToPoints(0.511811023622047)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = -3
.CenterHorizontally = True
.CenterVertically = True
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
.PrintErrors = xlPrintErrorsDisplayed
End With
ActiveWindow.SelectedSheets.PrintPreview
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("Sheet1").Select
ActiveWindow.SelectedSheets.Delete
End Sub
Do onkey events fire when a user form is open?
I have a userform that has 7 tabs
Tab 7 contains an imagecontrol that shows various images.
I want a method of printing the image when a user presses Ctrl & p
This identifies that page 7 is active
Private Sub MultiPage1_Change()
If MultiPage1.Value = 7 Then
Application.OnKey "^p", "PrintImage(imgFile)"
End If
End Sub
This should then call this routine
Sub PrintImage(imgFile As String)
'MsgBox "Do you want to print " & imgFile
Application.Worksheets.Add
ActiveSheet.Pictures.Insert(imgFile).Select
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = "Colours may not be as shown"
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.748031496062992)
.RightMargin = Application.InchesToPoints(0.748031496062992)
.TopMargin = Application.InchesToPoints(0.984251968503937)
.BottomMargin = Application.InchesToPoints(0.984251968503937)
.HeaderMargin = Application.InchesToPoints(0.511811023622047)
.FooterMargin = Application.InchesToPoints(0.511811023622047)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = -3
.CenterHorizontally = True
.CenterVertically = True
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
.PrintErrors = xlPrintErrorsDisplayed
End With
ActiveWindow.SelectedSheets.PrintPreview
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("Sheet1").Select
ActiveWindow.SelectedSheets.Delete
End Sub
Do onkey events fire when a user form is open?