Solved Print a landscape form

zelarra821

Registered User.
Local time
Tomorrow, 00:26
Joined
Jan 14, 2019
Messages
842
Buenas tardes.

I am trying to print a form, and I have succeeded in this way:

Code:
Private Sub CdmImprimir_Click()
    On Error GoTo err_lbl
    
    Dim Titulo As String
    Dim Ruta As String
    
    Titulo = Screen.ActiveForm.Caption
    Ruta = BuscaCarpeta(Me)
    
    If Ruta = "" Then
        Exit Sub
    Else
    DoCmd.OutputTo acOutputForm, , acFormatPDF, Ruta & "\" & Titulo & ".pdf", 1
    End If
Salida:
    Exit Sub
err_lbl:
    MsgBox "CdmImprimir: " & Err.Number & " " & Err.Description, vbInformation, NombreBD
    Resume Salida
End Sub

However, I would like to change the orientation of the PDF, so that instead of portrait it comes out as landscape.

How can I get it?

I have the BuscaCarpeta function in a module, because I use it in more places, and basically what it does is return the path of the folder that the user has selected.

Thanks.
 
Normalmente, you would print a report and not a form. Is there any way you could create a report instead? Just curious...
 
I had already thought about it, but I have a graph that I change with checkboxes and combos as I am interested, and I do not know if that will be possible to do in a report. Look:

ScreenShot001.jpg
 
Well, it's easier than I thought. With this line before printing it is solved:

Code:
Forms (Me.Name) .Printer.Orientation = acPRORLandscape

That is, the first code that I have put would look like this:

Code:
Private Sub CdmImprimir_Click()
    On Error GoTo err_lbl

    Dim Titulo As String
    Dim Ruta As String

    Titulo = Screen.ActiveForm.Caption
    Ruta = BuscaCarpeta(Me)

    If Ruta = "" Then
        Exit Sub
    Else
    Forms(Me.Name).Printer.Orientation = acPRORLandscape
    DoCmd.OutputTo acOutputForm, , acFormatPDF, Ruta & "\" & Titulo & ".pdf", 1
    End If
Salida:
    Exit Sub
err_lbl:
    MsgBox "CdmImprimir: " & Err.Number & " " & Err.Description, vbInformation, NombreBD
    Resume Salida
End Sub

Thanks
 
Well, it's easier than I thought. With this line before printing it is solved:

Code:
Forms (Me.Name) .Printer.Orientation = acPRORLandscape

That is, the first code that I have put would look like this:

Code:
Private Sub CdmImprimir_Click()
    On Error GoTo err_lbl

    Dim Titulo As String
    Dim Ruta As String

    Titulo = Screen.ActiveForm.Caption
    Ruta = BuscaCarpeta(Me)

    If Ruta = "" Then
        Exit Sub
    Else
    Forms(Me.Name).Printer.Orientation = acPRORLandscape
    DoCmd.OutputTo acOutputForm, , acFormatPDF, Ruta & "\" & Titulo & ".pdf", 1
    End If
Salida:
    Exit Sub
err_lbl:
    MsgBox "CdmImprimir: " & Err.Number & " " & Err.Description, vbInformation, NombreBD
    Resume Salida
End Sub

Thanks
Hi. Congratulations! Glad to hear you got it sorted out. Good luck with your project.
 
FWIW, the only time I ever needed to print a form (in landscape view), I used an autokeys macro to perform a screengrab using a keyboard shortcut Shift +F3, then printed the resulting image.
It worked...but using a report is much better! And yes, you can replicate your form chart items easily in a report
 
Ok, thank you very much, I'll test what you say.
 

Users who are viewing this thread

Back
Top Bottom