ByteScout Premium Suite - VB.NET - Generate word document with barcodes with barcode sdk - ByteScout

ByteScout Premium Suite – VB.NET – Generate word document with barcodes with barcode sdk

  • Home
  • /
  • Articles
  • /
  • ByteScout Premium Suite – VB.NET – Generate word document with barcodes with barcode sdk

How to generate word document with barcodes with barcode sdk in VB.NET with ByteScout Premium Suite

Learn to generate word document with barcodes with barcode sdk in VB.NET

The sample source codes on this page shows how to generate word document with barcodes with barcode sdk in VB.NET. Want to generate word document with barcodes with barcode sdk in your VB.NET app? ByteScout Premium Suite is designed for it. ByteScout Premium Suite is the set that includes 12 SDK products from ByteScout including tools and components for PDF, barcodes, spreadsheets, screen video recording.

Want to quickly learn? This fast application programming interfaces of ByteScout Premium Suite for VB.NET plus the guidelines and the code below will help you quickly learn how to generate word document with barcodes with barcode sdk. Just copy and paste the code into your VB.NET application’s code and follow the instructions. Complete and detailed tutorials and documentation are available along with installed ByteScout Premium Suite if you’d like to learn more about the topic and the details of the API.

Our website gives trial version of ByteScout Premium Suite 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)

Program.vb
      
' 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

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Premium Suite Home Page

Explore ByteScout Premium Suite Documentation

Explore Samples

Sign Up for ByteScout Premium Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

VIDEO

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Premium Suite Home Page

Explore ByteScout Premium Suite Documentation

Explore Samples

Sign Up for ByteScout Premium Suite Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Tutorials:

prev
next