|
感谢“yuanhongly”及“ddmc”无私分享,因要生成二维码到指定的表格image控件,但生成的二维码无法自适应大小,烦请各位帮忙解决,谢谢,如图如附件。
Private Sub Command1_Click()
Dim b2() As Byte
Dim s As String
Dim i As Long, m As Long
If Cmb1.ListIndex < 0 Then Exit Sub
If Cmb2.ListIndex < 0 Then Exit Sub
If CMB3.ListIndex < 0 Then Exit Sub
If CMB4.ListIndex < 0 Then Exit Sub
Select Case CMB4.ListIndex
Case 1
s = Text1.Text
m = Len(s)
i = m * 3 + 64
ReDim b2(i)
m = WideCharToMultiByte(CP_UTF8, 0, ByVal StrPtr(s), m, b2(0), i, ByVal 0, ByVal 0)
Case Else
s = StrConv(Text1.Text, vbFromUnicode)
b2 = s
m = LenB(s)
End Select
Set Image1.Picture = obj.Encode(b2, m, Cmb1.ListIndex, Cmb2.ListIndex + 1, CMB3.ListIndex - 1)
ActiveSheet.OLEObjects("Image1").Object.Picture = obj.Encode(b2, m, Cmb1.ListIndex, Cmb2.ListIndex + 1, CMB3.ListIndex - 1)
End Sub
如下图:
|
|