ByteScout BarCode Generator SDK - Microsoft Word - Add Barcode to Word Document in VB.NET - ByteScout

ByteScout BarCode Generator SDK – Microsoft Word – Add Barcode to Word Document in VB.NET

  • Home
  • /
  • Articles
  • /
  • ByteScout BarCode Generator SDK – Microsoft Word – Add Barcode to Word Document in VB.NET

How to add barcode to word document in VB in Microsoft Word using ByteScout Barcode SDK

How to code in Microsoft Word to add barcode to word document in VB with this step-by-step tutorial

The documentation is designed to help you to implement the features on your side. ByteScout Barcode SDK 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 be used to add barcode to word document in VB using Microsoft Word.

You will save a lot of time on writing and testing code as you may just take the Microsoft Word code from ByteScout Barcode SDK for add barcode to word document in VB below and use it in your application. In your Microsoft Word project or application you may simply copy & paste the code and then run your app! This basic programming language sample code for Microsoft Word will do the whole work for you to add barcode to word document in VB.

ByteScout Barcode SDK free trial version is available on our website. Microsoft Word and other programming languages are supported.

Try ByteScout Barcode SDK today:  60 Day Free Trial (on-premise) or  Web API (on-demand version)

Module1.vb
      
' IMPORTANT: ' Copy input.doc to your my documents folder ' and change the path to "input.doc" below ' Word requires to provide absolute path to input files ' ' Imports System Imports System.Collections.Generic Imports System.Drawing Imports System.IO Imports System.Text Imports System.Windows.Forms Imports Bytescout.BarCode Module Module1 <STAThread()> _ Sub Main() ' Create new barcode Dim barcode As New Barcode() ' Set symbology barcode.Symbology = SymbologyType.Codabar ' Set value barcode.Value = "123456" ' Add checksum to barcode barcode.AddChecksum = True ' Create word instance Dim appWord As New Microsoft.Office.Interop.Word.Application() ' Hide word appWord.Visible = False ' Create missing object Dim mis As Object = System.Reflection.Missing.Value ' Template file - change to the appropraite path where you copied input.doc Dim fileInput As Object = "C:\input.doc" ' Template file - change to the appropraite path where you copied input.doc Dim fileOutput As Object = "C:\output.doc" ' Open document Dim docWord As Microsoft.Office.Interop.Word.Document = appWord.Documents.Open(fileInput, mis, mis, mis, mis, mis, mis, mis, mis, mis, mis, mis, mis, mis, mis, mis) ' Set bookmark name Dim bookmarkName As Object = "MyBookmark" ' Get bookmark location Dim bookmarkLocation As Microsoft.Office.Interop.Word.Range = docWord.Bookmarks(bookmarkName).Range() ' Get barcode image Dim image As Bitmap = DirectCast(barcode.GetImage(), Bitmap) ' Copy image to the clipboard Clipboard.SetDataObject(image) ' Paste barcode image to the document bookmarkLocation.Paste() ' Save to the new document docWord.SaveAs(fileOutput, mis, mis, mis, mis, mis, mis, mis, mis, mis, mis, mis, mis, mis, mis, mis) ' We needn't save changes Dim saveChanges As Object = False ' Close word application appWord.Quit(saveChanges, mis, mis) ' Release COM object System.Runtime.InteropServices.Marshal.ReleaseComObject(appWord) End Sub End Module

Try ByteScout Barcode SDK today:  60 Day Free Trial (on-premise) or  Web API (on-demand version)

VIDEO

ON-PREMISE VERSION INFORMATION

Get 60 Day Free Trial or Visit ByteScout Barcode SDK Home Page

Explore ByteScout Barcode SDK Documentation

Get ByteScout Barcode SDK Free Training

WEB API

Get Your Free API Key

Explore Web API Documentation

Tutorials:

prev
next