Je n'arrive pas à comprendre comment je peux imprimer les fichiers PDF dans l'ordre (ordre de la liste des cellules).Comment imprimer des fichiers pdf dans l'ordre de la liste de cellules en utilisant Excel-VBA?
Sub PrintPDFFiles()
zProg = "C:\Program Files\Adobe\Reader 11.0\Reader\AcroRd32.exe"
zLastRow = [a65536].End(xlUp).Row
temp = "a1:a" & zLastRow
zPrinter = "HP LaserJet Professional M1213nf MFP "
For Each cell In Range(temp)
zFile = cell.Value
If zFile Like "*.pdf" Then
Shell """" & zProg & """/n /h /t""" & zFile & """"
End If
Next
End Sub
recherche Je l'ai fait jusqu'à présent:
Aucune ligne de commande switch pour imprimer des fichiers dans l'ordre.
Mise à jour-1 MyCode Après Suggestions:
je object.run méthode dans mon code et j'obtiens l'erreur:
Sub PrintPDFFiles()
zProg = "C:\Program Files\Adobe\Reader 11.0\Reader\AcroRd32.exe"
zLastRow = [a65536].End(xlUp).Row
temp = "a1:a" & zLastRow
zPrinter = "HP LaserJet Professional M1213nf MFP "
For Each cell In Range(temp)
zFile = cell.Value
If zFile Like "*.pdf" Then
Dim wsh As Object
Set wsh = VBA.CreateObject("WScript.Shell")
Dim waitOnReturn As Boolean: waitOnReturn = True
Dim windowStyle As Integer: windowStyle = 1
zCommand = zProg & " /n /h /t " & Chr(34) & zFile & Chr(34) & " " & zPrinter
wsh.Run zCommand, windowStyle, waitOnReturn
End If
Next
End Sub
Erreur:
Update-2 Mon code Afte r Suggestions:
wsh.Run """Acrobat.exe"" /n /h /t" & Chr(34) & zfile & Chr(34) & " " & zPrinter, , waitOnReturn
Problème: I réussi à imprimer en utilisant la méthode d'exécution, mais je dois fermer Adobe Acrobat Reader après chaque fichier. Je dois imprimer plus de 500 fichiers.
Vous êtes ** Shell ** ing dans une boucle; Êtes-vous sûr qu'un ** Shell ** se termine avant que le prochain soit lancé ?? –
Est-ce qu'Adobe reste ouvert jusqu'à la fin de l'impression? Que faire si vous essayez de déclarer Adobe en tant qu'objet, Imprimer, Adobe.Quit, puis "Ne pas Adobe n'est rien". Je n'ai pas trop d'expérience avec la manipulation d'Adobe, mais c'est une méthode possible. –
Voir: https://stackoverflow.com/questions/15951837/wait-for-shell-command-to-complete –