2016-04-10 17 views
-2

誰かが次の問題で私を助けることができるかどうか疑問に思っています。Excelのバーコード

私は定期的にアイテムのスタッフ在庫エリアを持っています。ストッキングの一環として、彼らは彼らが発送するものについても請求する必要があります。問題は、彼らが請求するとき、彼らは彼らが充電する各項目のデータ入力の繰り返しタスクを行うことです。

私の理想的なセットアップでは、バーコードをスキャンすることができ、入力する必要があるすべてのデータがバーコードに格納されるため、タスクは数秒で完了します。

これを自動化するには、タブとともに必要なすべての入力をキャプチャし、入力する必要のあるキーを入力できるバーコードを1つ作成することを考えていました。自動的に請求されます。

バーコードを駆動するデータはExcelにありますので、Excelでバーコードを作成します。これは私が助けが必要なところです、私はバーコードのフォントを追加しようとしましたが、それは動作していません、それはVBAの経験が必要です。

+0

にrelatdよ、バーコードは、データ入力を自動化し、文字を送信し、キーボードのように見えます。おそらく、すべてのASCII文字を生成できるcode-128バーコードを使用できますが、結果のバーコードシンボルは、必要なデータ量と提供していない情報の量によって非常に長くなる可能性があります。 – Magoo

答えて

0

バーコード生成コンポーネントを使用して、VBAからバーコードを(写真として)生成し、これらの画像をExcelに挿入することができます。

以下は、ByteScout BarCode SDK(VBAと互換性のある市販コンポーネント)のサンプルコードです。sampleです。基本的には、VBAから呼び出されたときに画像を作成できる他のコンポーネントに置き換えることができます。

' IMPORTANT: This demo uses VBA so if you have it disabled please temporary enable 
' by going to Tools - Macro - Security.. and changing the security mode to ""Medium"" 
' to Ask if you want enable macro or not. Then close and reopen this Excel document 

' You should have evaluation version of the ByteScout SDK installed to get it working - get it from https://bytescout.com 

' If you are getting error message like 
' "File or assembly named Bytescout SDK, or one of its dependencies, was not found" 
' then please try the following: 
' 
' - Close Excel 
' - (for Office 2003 only) download and install this hotfix from Microsoft: 
' http://www.microsoft.com/downloads/details.aspx?FamilyId=1B0BFB35-C252-43CC-8A2A-6A64D6AC4670&displaylang=en 
' 
' and then try again! 
' 
' If you have any questions please contact us at http://bytescout.com/support/ or at [email protected] 


'============================================== 
'References used 
'================= 
'Bytescout Barcode SDK 
' 
' IMPORTANT: 
' ============================================================== 
'1) Add the ActiveX reference in Tools -> References 
'2) Loop through the values from the Column A for which barcode has to be generated 
'3) Parse the value to Bytescout Barcode Object to generate the barcode using QR Code barcode type. 
'4) Save the generated Barcode Image 
'5) Insert the Barcode Image in the Column B 
'6) Repeat the steps 3 to 5 till the last Value in Column A 
' 
'================================================================== 

Option Explicit 

' declare function to get temporary folder (where we could save barcode images temporary) 
Declare Function GetTempPath _ 
Lib "kernel32" Alias "GetTempPathA" _ 
(ByVal nBufferLength As Long, _ 
ByVal lpBuffer As String) As Long 

' function to return path to temporary folder 
Public Function fncGetTempPath() As String 
    Dim PathLen As Long 
    Dim WinTempDir As String 
    Dim BufferLength As Long 
    BufferLength = 260 
    WinTempDir = Space(BufferLength) 
    PathLen = GetTempPath(BufferLength, WinTempDir) 
    If Not PathLen = 0 Then 
     fncGetTempPath = Left(WinTempDir, PathLen) 
    Else 
     fncGetTempPath = CurDir() 
    End If 
End Function 


Sub Barcode_Click() 

'Fetch the Worksheet 
Dim mySheet As Worksheet 
Set mySheet = Worksheets(1)     'Barcode_Data Sheet 

'temp path to save the Barcode images 
Dim filePath As String 
filePath = fncGetTempPath()   'Change the Path But should end with Backslash(\) 

'Prepare the Bytescout Barcode Object 
'==================================== 
Dim myBarcode As New Bytescout_BarCode.Barcode 

myBarcode.RegistrationName = "demo"   'Change the name for full version 
myBarcode.RegistrationKey = "demo"   'Change the key for full version 

'Barcode Settings 
myBarcode.Symbology = SymbologyType_QRCode ' QR Code barcode, you may change to other barcode types like Code 39, Code 128 etc 

' set barcode image quality resolution 
myBarcode.ResolutionX = 300     'Resolution higher than 250 is good for printing 
myBarcode.ResolutionY = 300     'Resolution higher than 250 is good for printing 

myBarcode.DrawCaption = True    'Showing Barcode Captions in the Barcode Image 
myBarcode.DrawCaptionFor2DBarcodes = True ' show captions for 2D barcodes like QR Code 

' first clean the B column from old images (if any) 
Dim Sh As Shape 
With mySheet 
    For Each Sh In .Shapes 
     If Not Application.Intersect(Sh.TopLeftCell, .Range("B1:B50")) Is Nothing Then 
     If Sh.Type = msoPicture Then Sh.Delete 
     End If 
    Next Sh 
End With 

' now generate new barcodes and insert into cells in the column B 
' Repeat the steps for each row from 2 to 6 
Dim myVal As Integer 

For myVal = 2 To 6       'change the code to all rows with values 
    'Parse the Value from the Column A to Bytescout Barcode Object 
    myBarcode.Value = mySheet.Cells(myVal, 1).Text 
    'Fit the barcode into 80X30 mm rectangle 
    myBarcode.FitInto_3 80, 30, 4   '4 refers to units of measurement as millimeter 
    'Save the barcode image to a file in temporary folder 
    myBarcode.SaveImage filePath & "myBarcode" & myVal & ".png" 

    'Insert the Barcode image to the Column B and resize them to fit the cell. 
    '========================================================================== 
    With mySheet.Pictures.Insert(filePath & "myBarcode" & myVal & ".png") 
     .ShapeRange.LockAspectRatio = True ' lock aspect ratio 
     .Left = mySheet.Cells(myVal, 2).Left + 1 ' set left 
     .Top = mySheet.Cells(myVal, 2).Top + 1 ' set right 
     .PrintObject = True ' allow printing this object 
     .Placement = xlMove ' set placement mode to move but do not resize with the cell 
     .ShapeRange.ScaleHeight 1, True ' set height scale to 1 (no scale) 
     .ShapeRange.ScaleWidth 1, True ' set width scale to 1 (no scale) 
    End With 


Next myVal ' move to next cell in the column 

' Release the Barcode Object. 
Set myBarcode = Nothing 

End Sub 

免責事項:私は基本的にByteScout

関連する問題