ByteScout Premium Suite - Microsoft Word - Add barcode to Word document in VB with BarCode SDK.NET - ByteScout

ByteScout Premium Suite – Microsoft Word – Add barcode to Word document in VB with BarCode SDK.NET

  • Home
  • /
  • Articles
  • /
  • ByteScout Premium Suite – Microsoft Word – Add barcode to Word document in VB with BarCode SDK.NET

How to add barcode to word document in VB with barcode SDK in Microsoft Word and ByteScout Premium Suite

If you want to learn more then this tutorial will show how to add barcode to word document in VB with barcode SDK in Microsoft Word

This sample source code below will display you how to add barcode to word document in VB with barcode SDK in Microsoft Word. ByteScout Premium Suite can add barcode to word document in VB with barcode SDK. It can be applied from Microsoft Word. ByteScout Premium Suite is the bundle that includes twelve SDK products from ByteScout including tools and components for PDF, barcodes, spreadsheets, screen video recording.

These Microsoft Word code samples for Microsoft Word guide developers to speed up coding of the application when using ByteScout Premium Suite. Follow the instructions from scratch to work and copy the Microsoft Word code. Enjoy writing a code with ready-to-use sample Microsoft Word codes.

You can download free trial version of ByteScout Premium Suite from our website with this and other source code samples for Microsoft Word.

On-demand (REST Web API) version:
 Web API (on-demand version)

On-premise offline SDK for Windows:
 60 Day Free Trial (on-premise)

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

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