I am trying to create a VBA code to read input from a barcode scanner. Specifically I'm interested in reading code 128 barcodes. I read on a different post that the barcode scanner is basically a "keyboard" that types the input when scanning to the application. I don't whether this can be replicated in Excel using VBA. Any ideas will be appreciated.
I am looking for something like this:
Sub BarcodeScannerReader()
Dim sMyCode As String
sMyCode=input("Scan Code:")
Range("A1"). Value=sMyCode
End Sub
You need the barcode fonts installed, and your barcode reader set up to write to the cell you're interested in. The scanner really does work like a keyboard - it will read the code and 'type' the results wherever you direct it to. This isn't something you do in VBA (unless I'm misunderstanding your question).
Related
I am new to libreoffice basic, i have experience with VBA but this libreoffice is different.
I just want to get cell value but it always return zero value to me while the actuall cell can be text or number.
Here is a partial of my simple code.
Sub test_moved()
Dim Doc As Object
'worksheet
Dim sh_village As Object
Dim sh_cbc As Object
sh_village = ThisComponent.CurrentController.getActiveSheet()
'sh_village = Doc.Sheets.getByName("VillageFinal")
'sh_village = Doc.Sheets(1)
Msgbox(sh_village.getCellrangeByName("B2").getValue())
Msgbox(sh_village.getCellrangeByName("B2").Value)
Msgbox(sh_village.getCellByPosition(1,1).Value)
msgbox("The process is completed.")
End Sub
Do we need to do prior task before start coding?
The code works correctly for numeric values. However, for strings, including strings that look like a number, it will display 0 because there is no numeric value.
What you probably want instead is:
MsgBox(sh_village.getCellRangeByName("B2").getString())
Also check out Format -> Cells -> Number to see how the data is displayed in the cell. And be on the lookout for a single quote at the front of the value in the formula bar (for example '42), because that means it is a string. Delete the quote to make it a number.
i have experience with VBA but this libreoffice is different.
Yes, LibreOffice Basic is a different language from VBA and the LibreOffice API is very different from the MS Office API. Knowing that will help you use it more effectively. If possible, avoid Option Compatible, because it won't fix most problems and will only muddy the waters.
I am trying to export through a Macro in MS Word a String that has 4 numbers. The whole Macro runs just fine, but, when I open the resulting PDF, I see that the barcode displayed seems corrupt.
This is the result:
In the Macro, I select the text I want to format, and change the font to "Free 3 of 9 Extended".
I have tried wrapping this number with "*" characters without success. Also tried "!". None of this seems to work. The funny part is that, if I open a Word document and type the same numbers using the same font, a clear Barcode is displayed:
This is what I see when writing directly in MS Word the same characters using the same font,this is what I see (which is what I want to achieve in the PDF export).
My macro exports to PDF with the following code:
Public Function guardar(id As String) As String
Dim path As String
guardar = id
obj_Word.ActiveDocument.ExportAsFixedFormat OutputFileName:=guardar,
OptimizeFor:=wdExportOptimizeForPrint, UseISO19005_1:=True,
IncludeDocProps:=True, KeepIRM:=True, ExportFormat:=wdExportFormatPDF
End Function
Is it possible that the template you are given is setting the font weight to bold in that portion of the document in which you are introducing the barcode, thus modifying the way it is displayed?
I cannot think of any other reason. The code you are posting does not seem to be the culprit.
After much trial and error ,and with assistance from the community, the ability to use Unicode in a form has not been very successful. So the question is. Is there a method to have the ability to use Unicode within a form ? primarily in textbox control were a currency symbol like the Peso symbol(₱) will appear in a textbox. there are various ways to have it on a worksheet but in a form is an allusive task.
After much trial and error ,and with assistance from the community, the ability to use Unicode in a form has not been very successful.
Says who? :)
Private Sub UserForm_Initialize()
TextBox1.Text = ChrW(8369)
End Sub
And welcome to stackoverflow :)
Among other methods, you could:
copy & paste Unicode into a textbox, or,
or use ChrW to use a specific character like this:
UserForm1.TextBox1 = ChrW(8369) 'puts a ₱ in the text box.
Note that in most cases the VBA Editor (VBE) won't display Unicode (so copy/pasting the above code into your VBE will replace the ₱ with a ?).
By the way CodePoints is a handy site for finding/identifying unicode symbols. Type whatever you're looking for in the search bar, or copy & paste from a website to find out more.
Also, note that all symbols that appear on your system may or or may not render properly on others.
I am fairly new to vba. Appologies if this is a simple question, but after 3 days on google im starting to feel dumb.
I am writing a very simple POS program to take stock in a bar. Part of the program is a Till point function. I am writing in excel VBA. I have a generic pos printer connected to a generic cash drawer. Printer is connected via usb to pc.
My question: i am unable to get the cash drawer to kick open when a receipt is printed. It is printing the reciepts fine, but i do not how how to send a ascii - esc/pos command to the printer.
I know that i should use "chr(27), chr(112)" , but how?!
As a last resort Ive tried pasting those chars in a cell and used cells("A1").printout function but that just sends it to the printer as text to be printed and not a command.
Any help would be greatly appreciated.
Marchant
This link suggests:
Option Explicit
Sub testme01()
Open "LPT1:" For Output As #1
Print #1, chr(27)+chr(112)
Close #1
End Sub
I have an Epson Display Unit (for the Point of Sale), and have it set up as a printer. I can only get it to print what I want when I go to Printer Properties > Fonts (there is a test input box).
However printing from an app such as notepad yields no results. I'm trying to get it to work with the p.o.s. app I made in Excel. I found a COMM port communication script here, but I can't get past the OPEN command. Seems there's a "file in use". I'd like to know if anyone else has had experience with this sort of thing.
Under the assumption that your printer is connected to serial interface 1, provided that the serial interface parameters are correctly set, and you want to send a string of characters to that interface, you may try this ...
Sub WriteToCOM()
Open "COM1:" For Output As #1
Write #1, "ddd"
Close #1
End Sub
Paste this code into an Excel VBA script and cycle thru it with F8 - it worked for me
You may replace "COM1:" by any existing "COMx:" or "LPTx:" as well (don't forget the semicolon!)
I am using this to control an Amateur Radio (setting the frequency) from an Excel table containing broadcast station names and their frequencies. I am of course sending special characters to my gear using the chr() function.
The Macro is tied to a control button. My Excel is Office 2003 (it worked already in Office97)
Good luck
MikeD