天天看點

Excel 條形碼生成(BarCode)

'**********************************************************************
    ' @(f)
    '
    '機能  : バーコードを作成
    '
    '返り値 :
    '
    '引き數 : 
    '              
    '機能説明:
    '
    '備考  :
    '
    '**********************************************************************
    Private Function PF_CreateBarcode(ByVal ExcelUtil_eu As ExcelUtil, ByVal CurrentCell As String, ByVal Top_i As Integer, ByVal left_i As Integer)
        ExcelUtil_eu.m_xApp.ScreenUpdating = False
        ExcelUtil_eu.m_xApp.Calculation = Excel.XlCalculation.xlCalculationManual
        ExcelUtil_eu.m_xApp.Interactive = False
        System.Windows.Forms.Application.DoEvents()
        ExcelUtil_eu.m_xSheet.OLEObjects.Add(ClassType:="BARCODE.BarcodeCtrl.1", Link:=True, _
                                               DisplayAsIcon:=False, Width:=200, Height:=250, Top:=Top_i, _
                                               Left:=left_i)
        Dim MyBarcode As String
        Dim objBarCode As BARCODELib.BarCodeCtrl
        MyBarcode = ExcelUtil_eu.m_xSheet.Shapes.Item(ExcelUtil_eu.m_xSheet.Shapes.Count).Name
        Dim ole As Excel.OLEObject
        ole = ExcelUtil_eu.m_xSheet.OLEObjects(MyBarcode)
        With ole
            .AutoLoad = True
            .PrintObject = True
            .Visible = False
            .Placement = 2
            .LinkedCell = CurrentCell
            .Visible = True
        End With
        objBarCode = ole.Object
        With objBarCode
            .Style = 5          ' 5:NW-7
            .SubStyle = 0
            .Validation = 0     ' C/D修正有り
            .ShowData = 1       ' 數値表示
            .Value = "a" & ExcelUtil_eu.m_xSheet.Range(CurrentCell).Value & "a"
            .Refresh()
        End With
        ExcelUtil_eu.m_xSheet.m_xApp.Interactive = True
        ExcelUtil_eu.m_xSheet.m_xApp.Calculation = Excel.XlCalculation.xlCalculationAutomatic
        ExcelUtil_eu.m_xSheet.m_xApp.ScreenUpdating = True
    End Function      

 本博版權所有!轉載注明出處!