Auto Barcode Generation for CorelDRAW X4 using VBA
The main idea is "How to automate creation of barcode in CorelDraw?"
While creating barcode object from code is impossible, we have another trick to help.
We can repeat the `job` of manually creating barcode within a script. The barcode number is taken from a file. Here the script:
Dim thecode As String
Set MyData = New DataObject
Open "c:\file-barcode.csv" For Input As #1
Do While Not EOF(1)
Line Input #1, thecode
MyData.SetText thecode
MyData.PutInClipboard
With CorelScript
.InsertOLEObject "CorelBARCODE.14"
.OLEObjectDoVerb 0
End With
SendKeys "^{V}", True
SendKeys "{ENTER}", True
SendKeys "{ENTER}", True
SendKeys "{ENTER}", True
'MsgBox fi(0)
Loop
Close #1
If DataObject not exist, you can add references to `Microsoft Forms 2.0 object Library`
Before using the script You can manually create barcode, set the format, scale etc. This setting is remembered by corelDRAW for next barcode created.
Once You fix with the barcode shape and size, you can run this script and create as many as barcode you want.
But remember, this process require reasonably fast computer. And you cannot do another work while the script is runnig.
While creating barcode object from code is impossible, we have another trick to help.
We can repeat the `job` of manually creating barcode within a script. The barcode number is taken from a file. Here the script:
Dim thecode As String
Set MyData = New DataObject
Open "c:\file-barcode.csv" For Input As #1
Do While Not EOF(1)
Line Input #1, thecode
MyData.SetText thecode
MyData.PutInClipboard
With CorelScript
.InsertOLEObject "CorelBARCODE.14"
.OLEObjectDoVerb 0
End With
SendKeys "^{V}", True
SendKeys "{ENTER}", True
SendKeys "{ENTER}", True
SendKeys "{ENTER}", True
'MsgBox fi(0)
Loop
Close #1
If DataObject not exist, you can add references to `Microsoft Forms 2.0 object Library`
Before using the script You can manually create barcode, set the format, scale etc. This setting is remembered by corelDRAW for next barcode created.
Once You fix with the barcode shape and size, you can run this script and create as many as barcode you want.
But remember, this process require reasonably fast computer. And you cannot do another work while the script is runnig.
Komentar
Posting Komentar