Re : VBA - Impressions pas dans l'ordre
Bonjour,
Par contre, j'ai un autre souci sur ma macro Impression.
Imaginons que j'ai une imprimante par défaut. Et dans ma macro, je choisis une autre imprimante. Chez moi, l'imprimante choisie est bien sélectionné.
Par contre, à mon travail, j'ai une imprimante hp branchée en usb sur ma tour et le photocopieur qui est sur le réseau de la société.
Et dans ce cas là, l'imprimante choisie n'est pas prise en compte et imprime automatiquement sur l'imprimante par défaut sur le pc. Pour forcer l'impression sur le photocopieur, je dois le meme en imprimante par défaut. Galère!!!
voici la macro.
Sub Impression()
Dim i As Integer
Dim TexteRecherche As String
Dim ImprimanteChoisie As String, ImprimanteInitiale As String
ImprimanteInitiale = Application.ActivePrinter
Application.Dialogs(Excel.XlBuiltInDialog.xlDialogPrinterSetup).Show
ImprimanteChoisie = Application.ActivePrinter
Application.ScreenUpdating = False
Select Case ChoixImpression
Case "Tous les fichiers"
For i = 6 To FinTableau
Fichier = Cells(3, 2).Value & "\" & Cells(i, 2).Value
ShellExecute 0&, "print", Fichier, vbNullString, vbNullString, vbNormalFocus
Cells(i, 3).Value = "Fichier imprimé"
Next
Case "Uniquement Type1"
For i = 6 To FinTableau
Fichier = Cells(3, 2).Value & "\" & Cells(i, 2).Value
If Cells(i, 2).Value Like "*Type1*" Then
ShellExecute 0&, "print", Fichier, vbNullString, vbNullString, vbNormalFocus
Cells(i, 3).Value = "Fichier imprimé"
End If
Next
Case "Uniquement Type2"
For i = 6 To FinTableau
NomFichier = Cells(i, 2).Value
TexteRecherche = "xxx"
Position = InStr(1, NomFichier, TexteRecherche, vbTextCompare)
If Position = 0 Then
Fichier = Cells(3, 2).Value & "\" & Cells(i, 2).Value
ShellExecute 0&, "print", Fichier, vbNullString, vbNullString, vbNormalFocus
Cells(i, 3).Value = "Fichier imprimé"
End If
Next
End Select
Application.ScreenUpdating = True
MsgBox "Les fichiers ont bien été imprimés"
Application.ActivePrinter = ImprimanteInitiale
End Sub
Je pense que je ne maitrise pas le fait que l'imprimantephotocopieur soit en réseau.
Merci de votre aide.
Jehnkira