• Privacywetgeving
    Het is bij Helpmij.nl niet toegestaan om persoonsgegevens in een voorbeeld te plaatsen. Alle voorbeelden die persoonsgegevens bevatten zullen zonder opgaaf van reden verwijderd worden. In de vraag zal specifiek vermeld moeten worden dat het om fictieve namen gaat.

Userform horizontaal afdrukken

Status
Niet open voor verdere reacties.

toverkamp

Gebruiker
Lid geworden
11 sep 2006
Berichten
403
Hallo Excelliefhebbers,

Ik heb een vraagje. Op een userform heb ik een printknop gemaakt, waar de volgende code achter zit:
Code:
Private Sub CmbAfdrukkenStoringPerFiliaal_Click()
CmbAfdrukkenStoringPerFiliaal.Visible = False
CmbAnnuleerStoringPerFiliaal.Visible = False
StoringPerFiliaal.PrintForm
CmbAfdrukkenStoringPerFiliaal.Visible = True
CmbAnnuleerStoringPerFiliaal.Visible = True
End Sub

Het probleem is nu echter dat het halve userform maar zichtbaar is. Is het ook mogelijk om ervoor te zorgen dat het userform horizontaal wordt afgedrukt?
 
Private Sub CmbAfdrukkenStoringPerFiliaal_Click()
CmbAfdrukkenStoringPerFiliaal.Visible = False
CmbAnnuleerStoringPerFiliaal.Visible = False
StoringPerFiliaal.PrintForm
CmbAfdrukkenStoringPerFiliaal.Visible = True
CmbAnnuleerStoringPerFiliaal.Visible = True
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.787401575)
.RightMargin = Application.InchesToPoints(0.787401575)
.TopMargin = Application.InchesToPoints(0.984251969)
.BottomMargin = Application.InchesToPoints(0.984251969)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
.PrintErrors = xlPrintErrorsDisplayed
End With
End Sub


bovenstaande variabelen zijn natuurlijk aan te passen naar je wens.

Zoiets??
 
Allereerst bedankt voor uw reactie!
Dit is (volgens mij) nie precies wat ik bedoel. Het formulier staat er nog steeds maar half op. Het is eigenlijk de bedoeling dat de pagina-instelling "liggend" is. Het formulier heeft namelijk de gehele breedte van een liggende pagina (A4).
 
kun je het formulier bijsluiten, dan kijk ik wel even of ik hem aan kan passen
 
Dit is een stuk code uit 1 van mijn bestanden.

Code:
Public Const VK_SNAPSHOT = &H2C 'this is and the line below are needed to print the form landscape
Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, _
                                      ByVal bScan As Byte, _
                                      ByVal dwFlags As Long, _
                                      ByVal dwExtraInfo As Long)

Private Sub PrintFormLandscape()
    
    'to print the main userform in landscape
    
    Dim wsTemp As Worksheet
    
    Application.ScreenUpdating = False
    
    keybd_event VK_SNAPSHOT, 1, 0, 0

    Set wsTemp = Sheets.Add(after:=Sheets(Sheets.Count))
    
    With wsTemp
    
        Application.Wait Now + TimeValue("00:00:01")
        
        'paste the userform in the temporary file
        .PasteSpecial Format:="Bitmap", Link:=False, DisplayAsIcon:=False
        
        'reduce the bitmap picture to fit on 1 page
        .Shapes(1).Height = .Shapes(1).Height * 0.5
        
        With .PageSetup
            
            'most important setting here
            .Orientation = xlLandscape
            
            'small margins
            .LeftMargin = Application.InchesToPoints(0.5)
            .RightMargin = Application.InchesToPoints(0.5)
            .TopMargin = Application.InchesToPoints(1)
            .BottomMargin = Application.InchesToPoints(1)
            
            .LeftHeader = "Printed on: " & Date
            
        End With
        
        .PrintOut
        
        Application.DisplayAlerts = False
        .Delete
        Application.DisplayAlerts = True
        
    End With
    
    Application.ScreenUpdating = True
    
End Sub

Wigi
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan