Sample source code below will show you how to cope with a difficult task like generate word document with barcodes in VB.NET. What is ByteScout Barcode SDK? It is the robost library (Software Development Kit) that is designed for automatic generation of high-quality barcodes for printing, electronic documents and pdf. All popular barcode types are supported from Code 39 and Code 129 to QR Code, UPC, GS1, GS-128, Datamatrix, PDF417, Maxicode and many others. Provides support for full customization of fonts, colors, output and printing sizes. Special tools are included to verify output quality and printing quality. Can add generated barcode into new or existing documents, images and PDF. It can help you to generate word document with barcodes in your VB.NET application.
The SDK samples like this one below explain how to quickly make your application do generate word document with barcodes in VB.NET with the help of ByteScout Barcode SDK. In your VB.NET project or application you may simply copy & paste the code and then run your app! Test VB.NET sample code examples whether they respond your needs and requirements for the project.
Our website provides trial version of ByteScout Barcode SDK for free. It also includes documentation and source code samples.
On-demand (REST Web API) version:
Web API (on-demand version)
On-premise offline SDK for Windows:
60 Day Free Trial (on-premise)
' This example uses Word Automation to create a document, add some text, add a table, ' fill it with random data and generate barcode images for it. Imports System.Drawing Imports System.Globalization Imports System.IO Imports System.Reflection Imports Microsoft.Office.Interop.Word Imports Word = Microsoft.Office.Interop.Word Imports Bytescout.BarCode Class Program Private Shared Sub Main(args As String()) Dim [optional] As Object = Missing.Value Dim endOfDocBookmark As Object = "\endofdoc" ' \endofdoc is a predefined bookmark ' start Word Dim word As _Application = New Application() word.Visible = False ' create new document Dim document As _Document = word.Documents.Add([optional], [optional], [optional], [optional]) ' insert a paragraph at the beginning of the document Dim paragraph1 As Paragraph = document.Content.Paragraphs.Add([optional]) paragraph1.Range.Text = "Heading 1" paragraph1.Range.Font.Bold = 1 paragraph1.Format.SpaceAfter = 24 ' 24 pt spacing after paragraph paragraph1.Range.InsertParagraphAfter() ' insert another paragraph Dim range As Object = document.Bookmarks.get_Item(endOfDocBookmark).Range Dim paragraph2 As Paragraph = document.Content.Paragraphs.Add(range) paragraph2.Range.Text = "This is a sentence of normal text. Now here is a table:" paragraph2.Range.Font.Bold = 0 paragraph2.Format.SpaceAfter = 24 paragraph2.Range.InsertParagraphAfter() ' insert a 5 x 2 table, make the first header row bold and italic range = document.Bookmarks.get_Item(endOfDocBookmark).Range Dim table As Table = document.Tables.Add(DirectCast(range, Range), 5, 2, [optional], [optional]) table.Cell(1, 1).Range.Text = "Value" ' 1st column header table.Cell(1, 2).Range.Text = "Barcode" ' 2nd column header table.Rows(1).Range.Font.Bold = 1 table.Rows(1).Range.Font.Italic = 1 AddBorders(table.Cell(1, 1).Range) AddBorders(table.Cell(1, 2).Range) Dim random As New Random() Dim tempImage As String = Path.Combine(Path.GetTempPath(), "tempImage.png") ' create barcode object Dim barcode As New Barcode("demo", "demo") barcode.Symbology = SymbologyType.Code128 barcode.DrawCaption = False ' fill the table with random data and add barcode images For row As Integer = 2 To 5 Dim randomValue As String = random.[Next]().ToString(CultureInfo.InvariantCulture) Dim cell As Range = table.Cell(row, 1).Range cell.Text = randomValue AddBorders(cell) ' generate barcode and save it to temporary image file barcode.Value = randomValue barcode.SaveImage(tempImage) ' put barcode image to second column cell = table.Cell(row, 2).Range cell.InlineShapes.AddPicture(tempImage, [optional], [optional], [optional]) AddBorders(cell) Next ' save document Dim fileName As Object = "sample.doc" ' use full file path in your app document.SaveAs(fileName, [optional], [optional], [optional], [optional], [optional], _ [optional], [optional], [optional], [optional], [optional], [optional], _ [optional], [optional], [optional], [optional]) ' quit Word Dim saveChanges As Object = True word.Quit(saveChanges, [optional], [optional]) System.Diagnostics.Process.Start(DirectCast(fileName, String)) End Sub ' Adds borders to provided Range Private Shared Sub AddBorders(cell As Range) AddressOf cell.Borders(WdBorderType.wdBorderLeft).LineStyle = WdLineStyle.wdLineStyleSingle AddressOf cell.Borders(WdBorderType.wdBorderTop).LineStyle = WdLineStyle.wdLineStyleSingle AddressOf cell.Borders(WdBorderType.wdBorderRight).LineStyle = WdLineStyle.wdLineStyleSingle AddressOf cell.Borders(WdBorderType.wdBorderBottom).LineStyle = WdLineStyle.wdLineStyleSingle End Sub End Class
60 Day Free Trial or Visit ByteScout Barcode SDK Home Page
Explore ByteScout Barcode SDK Documentation
Explore Samples
Sign Up for ByteScout Barcode SDK Online Training
Get Your API Key
Explore Web API Docs
Explore Web API Samples
60 Day Free Trial or Visit ByteScout Barcode SDK Home Page
Explore ByteScout Barcode SDK Documentation
Explore Samples
Sign Up for ByteScout Barcode SDK Online Training
Get Your API Key
Explore Web API Docs
Explore Web API Samples
also available as: