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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
| Option Compare Database
Option Explicit
Public 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
Function Impression_Zebra1()
'Déclaration de la variable et du type
'Variable : NomFichier ; Type : Texte
Dim NomFichier As String
'Variable : intFic ; Type : Nombre entier
Dim intFic As Integer
'Variable : ImpCherche ; Type : Objet (imprimante par défaut)
Dim ImpCherche As Printer
'Variable : Imprimante trouvée ; Type : True(Vrai)/False(Faux)
Dim ImprimanteTrouvée As Boolean
'Variable : NumImp ; Type : Nombre entier
Dim NumImp As Integer
'Variable : Compteur ; Type : Nombre entier
Dim Compteur As Integer
'Variable : NomFichier ; Type : Texte
Dim strPORT As String
Dim i As Integer
Dim iP As Integer
Dim prtImprim As Printer
Dim txtChaineCaractere As Variant
Dim Texte77 As Variant
'Fournir un numéro de fichier non utilisé
intFic = FreeFile
'Chemin d'accès
NomFichier = "C:\Users\loiseaua.EUOTIS\Desktop\Documentrelaiimpressionétiquette.txt"
'Ouvrir le document texte en écriture (vidé à chaque ouverture)
Open NomFichier For Output As intFic
'Écrire le programme ZPL (Saut de ligne automatique)
Print #intFic, "^XA"
Print #intFic, "^A0N,52,52^FO245,50^FD" & Texte77 & "^FS"
Print #intFic, "^BY2^FO230,115^BCN,120,N,N,N^FD" & txtChaineCaractere & "^FS"
Print #intFic, "^XZ"
'Fermeture du document texte
Close #intFic
iP = Application.Printers.Count
For i = 0 To iP - 1
Set prtImprim = Application.Printers(i)
'Debug.Print prtImprim.DeviceName
If prtImprim.DeviceName = "z40" Then
'imprimer sur cette imprimante-ci
ShellExecute 0, "print", NomFichier, vbNullString, "", 1
End If
Set prtImprim = Nothing
Next i
End Function |
Partager