Hallo Allemaal,
In de volgende macro wordt een PDF export gemaakt van alle sheets in het Excel bestand. Nu wil ik graag dat de print marge in deze code op "smal" wordt gezet.
Alvast bedankt!
In de volgende macro wordt een PDF export gemaakt van alle sheets in het Excel bestand. Nu wil ik graag dat de print marge in deze code op "smal" wordt gezet.
Alvast bedankt!
HTML:
Sub AllSheetsPDF()
Dim strSheets() As String
Dim strfile As String
Dim sh As Worksheet
Dim icount As Integer
Dim myfile As Variant
'Save Chart Sheet names to an Array
For Each sh In ActiveWorkbook.Worksheets
If sh.Visible = xlSheetVisible Then
ReDim Preserve strSheets(icount)
strSheets(icount) = sh.Name
icount = icount + 1
End If
Next sh
If icount = 0 Then 'No charts found. Punch error
MsgBox "De PDF kan niet worden gemaakt omdat er geen pagina's zijn.", , "No Sheets Found"
Exit Sub
End If
'Prompt for save location
strfile = "BLAD" & "_" & Range("C6") & ".pdf"
strfile = ThisWorkbook.Path & "\" & strfile
myfile = Application.GetSaveAsFilename _
(InitialFileName:=strfile, _
FileFilter:="PDF Files (*.pdf), *.pdf", _
Title:="Select Folder and File Name to Save as PDF")
If myfile <> "False" Then 'save as PDF
ThisWorkbook.Sheets(strSheets).Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
myfile, Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=True
Else
MsgBox "Geen bestand geselecteerd. De PDF wordt niet opgeslagen", vbOKOnly, "No File Selected"
End If
End Sub