On the Excel Ribbon, click the
Developer tab.
Then, click
Visual Basic in the Code group to open the "Microsoft Visual Basic for Applications" window
Double-click
ThisWorkbook in the Project window to open the code file.
Copy all following VB code to the code file.
- Create a new Application.COMAddIns("OnBarcode.OnBarcodeExcelAddIn") object
- Call method UpdateAllBarcode to update all barcodes in the Excel document
Sub CallVSTOMethod()
' Update contents of those cells in the Number column
Sheet1.Range("B4").Value = "1234567890123"
Sheet1.Range("B5").Value = "1234567890345"
Sheet1.Range("B6").Value = "1234567890567"
Sheet1.Range("B7").Value = "1234567890789"
' Get a COMAddIn object that represents the OnBarcode.OnBarcodeExcelAddIn VSTO Add-in.
Dim addIn As COMAddIn
Dim automationObject As Object
Set addIn = Application.COMAddIns("OnBarcode.OnBarcodeExcelAddIn")
' Get the Object property of the COMAddIn and call the UpdateAllBarcode method.
Set automationObject = addIn.Object
automationObject.UpdateAllBarcode
End Sub
Press F5 to run the code.
Then, four cells in the Number column have been updated to new values, and four linked Pictures (in Barcode column) have been refreshed by method UpdateAllBarcode.