'Déclaration des API'S 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 'Réduire le fichier à imprimer, ne pas l'activer Private Const SW_SHOWMINNOACTIVE = 7 Private Sub btn_print_Click() 'On lance l'impression avec l'API ShellExecute en passant comme paramètre 'd'opération "Print" et comme handle celui de la fenêtre. If txt_file <> "" Then r& = ShellExecute(Me.hwnd, "print", txt_file, ByVal 0&, 0&, SW_SHOWMINNOACTIVE) 'L'impression aura lieu si l'application ayant crée le fichier est capable d'imprimer 'et est inscrite dans la base de registre. If r& = 31 Then MsgBox "Impossible d'imprimer le fichier", vbCritical, " Erreur" End Sub
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 Private Sub Command1_Click() Dim Chemin As String, Fichier As String Chemin = "G:\mes documents\word" Fichier = Chemin & "MonFichier.doc" ShellExecute Me.hWnd, "print", Fichier, vbNullString, Chemin, Option_d _Affichage End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question