1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| 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
Dim NomFichier As String
Sub ImprimerFichier()
Dim x As Long
x = FindWindow("XLMAIN", Application.Caption)
ShellExecute x, "print", NomFichier, "", "", 1
End Sub
Private Sub CommandButton1_Click()
NomFichier = Range("A1").Value 'lien dans la cellule
ImprimerFichier
End Sub |
Partager