Last active
April 12, 2017 10:53
-
-
Save larsschenk/dbf532788124bccb324984601ba33bfb to your computer and use it in GitHub Desktop.
Access ActiveBarcode objects from Excel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' Avoid using ActiveSheet in your scripts | |
' if you are not sure if the active sheet remains active while | |
' running your VBA script. | |
' Best practise is to access the ActiveBarcode object via a variable | |
' That is stored for the whole livecycle of your script. | |
' Access the ActiveBarcode object without using ActiveSheet is | |
' shown here: | |
Public Sub AccessBarcode() | |
Dim MyBarcode ' Variable to access the barcode | |
' Change the name of the worksheet and the name of the barcode object if required: | |
Set MyBarcode = ThisWorkbook.Worksheets("Tabelle1").OLEObjects("Barcode1").Object | |
' Now you can access the barcode regardles of the active sheet via the variable: | |
MyBarcode.TypeName = "Code 128" | |
MyBarcode.Text = "My text" | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment