如上图所示,同样的内容,拉出不同的宽度(长度),其中123是扫描不出来的,只有4能扫描得到,请问一下大神,这个有什么说法吗?
现在的需求是效果是1或者2,效果4太长啦,不符合客户的模板要求,请问要如何解决?希望各位老师们指导一下,谢谢!
解决的方法如下:
首先,需要在使用的电脑上先安装Code 128字体(必须,已附).然后再调整一下字体大小就可以了
模块里的自定义函数:
Public Function GetCode128B(ByVal rn As Range) As String
Dim result As String, STR As String
Dim checksum As Integer, i_tmp As Integer
Dim checkCode As String '生成验证码
checksum = 104
STR = rn.Value
For i = 1 To Len(STR) Step 1
i_tmp = AscW(Mid(STR, i, 1))
If i_tmp >= 32 Then
checksum = checksum + (i_tmp - 32) * i
Else
checksum = checksum + (i_tmp + 64) * i
End If
Next
checksum = checksum Mod 103
If checksum < 95 Then
checksum = checksum + 32
Else
checksum = checksum + 100
End If
checkCode = ChrW(checksum)
result = ChrW(204) + STR + checkCode + ChrW(206)
GetCode128B = result
End Function
宏引用:
Sub 转化()
Dim n As Integer, i As Integer
n = Selection.Count
For i = 1 To n
If Selection.Cells(i) <> '' Then
Application.EnableEvents = False
Selection.Cells(i).Font.Name = 'Code 128'
Selection.Cells(i) = GetCode128B(Selection.Cells(i))
Application.EnableEvents = True
End If
Next
End Sub