Modifier les codes-barres sur un lot de codes-barres

Exemple : ajouter les zéros initiaux

Sub ModifCBParCodeBarre()
	Dim CodeBarre, DollarCodeBarre, NouveauCodeBarre
	Dim LesCodesBarres
	LesCodesBarres = Array("1009","101","1026","1027","1028","1029","1030","1031")
	For Each CodeBarre In LesCodesBarres
		Application.ActiveWindow.Command "che rbc 830622101 and slo Canope and cod " & CodeBarre
		If Application.ActiveWindow.Messages.Count = 0 Then
			DollarCodeBarre = "b" & CodeBarre
			Application.ActiveWindow.Command "mod", False
			Dim TrouveCodeBarre
			TrouveCodeBarre = Application.ActiveWindow.Title.Find(DollarCodeBarre, True, False, False)
			If TrouveCodeBarre = True Then
				NouveauCodeBarre = LPad(Mid(Application.ActiveWindow.Title.selection, 2), 6, "0")
				Application.ActiveWindow.Title.DeleteSelection
				Application.ActiveWindow.Title.InsertText "b" & NouveauCodeBarre
				Application.ActiveWindow.SimulateIBWKey("FR")
			End If
		Else
			InputBox "Problème", "Problème", Application.ActiveWindow.Messages.item(0) & ":" & CodeBarre
		End If
	Next
End Sub

Function LPad(s, l, c)
  Dim n
  n = 0
  If l > Len(s) Then n = l - Len(s)
  LPad = String(n, c) & s
End Function