1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String _
, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Sub ImprimerFichier()
Dim x As Long
Dim Chemin As String, DernièreLigne As Integer, i As Integer
DernièreLigne = Range("A65536").End(xlUp).Row
For i = 1 To DernièreLigne
If Range("B" & i).Value <> "" Then
Chemin = Range("B" & i).Value
x = FindWindow("XLMAIN", Application.Caption)
ShellExecute x, "print", Chemin, "", "", 1
End If
Next
End Sub |
Partager