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 63 64 65 66 67 68
| Option Compare Database
Option Explicit
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
'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^FDtxtChaineCaractere^FS"
Print #intFic, "^BY2^FO230,115^BCN,120,N,N,N^FDtxtChaineCaractere^FS"
Print #intFic, "^XZ"
'Fermeture du document texte
Close #intFic
ImprimanteTrouvée = False
'Initialisation des variables
NumImp = Application.Printers.Count
'Balayage de l'ensemble des imprimantes pour identifier celle que l'on cherche
For Each ImpCherche In Application.Printers
If ImpCherche.DeviceName = "z40" Then
ImprimanteTrouvée = True
strPORT = ImpCherche.Port
Exit For
End If
Compteur = Compteur + 1
Next ImpCherche
If ImprimanteTrouvée Then
FileCopy NomFichier, strPORT
Else
MsgBox "L'Imprimante nommée z40 n'a pas été trouvée", vbOKOnly, "erreur de configuration"
End If
Erreur:
MsgBox Err.Number & " : " & Err.Description
DoCmd.Echo True
'Fin de la procédure
End Function |
Partager