Mijn macro in Excel werkte perfect onder Win10, nu ik (helaas) ben overgestapt op Win11 krijg ik ineens een foutmelding.
:no_upscale():strip_icc():fill(white):strip_exif()/f/image/QRag1MiKbqNFHyiWn8XNI65o.jpg?f=user_large)
:no_upscale():strip_icc():fill(white):strip_exif()/f/image/ypkUR9lOJoWCXPPKhrx6ytX6.jpg?f=user_large)
Ik gebruik dus Win11 met Office 365 en Excel.
Ik heb hier eerder een post gehad met deze vraag en ik ben heel erg goed geholpen, ik kan deze post niet meer terugvinden.
:no_upscale():strip_icc():fill(white):strip_exif()/f/image/QRag1MiKbqNFHyiWn8XNI65o.jpg?f=user_large)
:no_upscale():strip_icc():fill(white):strip_exif()/f/image/ypkUR9lOJoWCXPPKhrx6ytX6.jpg?f=user_large)
Ik gebruik dus Win11 met Office 365 en Excel.
Ik heb hier eerder een post gehad met deze vraag en ik ben heel erg goed geholpen, ik kan deze post niet meer terugvinden.
'Written: November 28, 2009toon volledige bericht
'Author: Leith Ross
'Summary: Finds a printer by name and returns the printer name and port number.
Function FindPrinter(ByVal PrinterName As String) As String
'This works with Windows 2000 and up
Dim Arr As Variant
Dim Device As Variant
Dim Devices As Variant
Dim Printer As String
Dim RegObj As Object
Dim RegValue As String
Const HKEY_CURRENT_USER = &H80000001
Set RegObj = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
RegObj.enumvalues HKEY_CURRENT_USER, "Software\Microsoft\Windows NT\CurrentVersion\Devices", Devices, Arr
For Each Device In Devices
RegObj.getstringvalue HKEY_CURRENT_USER, "Software\Microsoft\Windows NT\CurrentVersion\Devices", Device, RegValue
Printer = Device & " on " & Split(RegValue, ",")(1)
If InStr(1, Printer, PrinterName, vbTextCompare) > 0 Then
FindPrinter = Printer
Exit Function
End If
Next
End Function
Sub PDFbriefpapier()
Dim bChoice As Boolean
bChoice = Application.Dialogs(xlDialogPrinterSetup).Show(ActivePrinter)
If Not bChoice Then
VBA.MsgBox "User cancelled"
Else
VBA.MsgBox ActivePrinter
End If
'
' PDFbriefpapier Macro
' Afdrukken als .pdf op blanco papier
'
' naam huidig werkblad opslaan
Dim strCurrentWorkBook As String
strCurrentWorkBook = ActiveWorkbook.Name ' stores the current active window
Dim strMyPrinter As String
strMyPrinter = FindPrinter("Microsoft Print to PDF")
Dim wbCurrent As Workbook
Set wbCurrent = ActiveWorkbook
' testfactuur openen, oude content verwijderen en weer vullen met de huidige factuur
Workbooks.Open Filename:= _
"D:\foldernaam\Correspondentie\Testfactuur.xlsx"
wbCurrent.Activate
Range("A1:F49").Select
Selection.Copy
Windows("Testfactuur.xlsx").Activate
ActiveSheet.Paste
' printgedeelte
Dim strCurrentPrinter As String
strCurrentPrinter = Application.ActivePrinter ' stores the current active (default) printer
Application.ActivePrinter = FindPrinter("Microsoft Print to PDF op Ne00:") ' change what is in quotes as per appropriate printer name in the Print Dialog Box
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
Application.ActivePrinter = strCurrentPrinter 'Returns printer output to your default printer
ActiveWindow.Close savechanges:=False
Range("A1").Select 'haalt het geselecteerde gebied weer weg door naar A1 te gaan
End Sub