ByteScout Premium Suite - Microsoft Word - Add barcode to Word document in C# with BarCode SDK - ByteScout

ByteScout Premium Suite – Microsoft Word – Add barcode to Word document in C# with BarCode SDK

  • Home
  • /
  • Articles
  • /
  • ByteScout Premium Suite – Microsoft Word – Add barcode to Word document in C# with BarCode SDK

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

Step-by-step tutorial on how to add barcode to word document in c# with barcode SDK in Microsoft Word

An easy to understand sample source code to learn how to add barcode to word document in c# with barcode SDK in 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. It can add barcode to word document in c# with barcode SDK in Microsoft Word.

Want to quickly learn? This fast application programming interfaces of ByteScout Premium Suite for Microsoft Word plus the guidelines and the code below will help you quickly learn how to add barcode to word document in c# with barcode SDK. Follow the instructions from scratch to work and copy the Microsoft Word code. 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.

ByteScout provides the free trial version of ByteScout Premium Suite along with the 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.cs
      
/* 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 */ using System; using System.Collections.Generic; using System.Drawing; using System.IO; using System.Text; using System.Windows.Forms; using Bytescout.BarCode; namespace InsertIntoMicrosoftWordDocument { class Program { [STAThread] static void Main(string[] args) { // Create new barcode Barcode barcode = new Barcode(); // Set symbology barcode.Symbology = SymbologyType.Codabar; // Set value barcode.Value = "123456"; // Add checksum to barcode barcode.AddChecksum = true; // Create word instance Microsoft.Office.Interop.Word.Application appWord = new Microsoft.Office.Interop.Word.Application(); // Hide word appWord.Visible = false; // Create missing object object mis = System.Reflection.Missing.Value; // Template file - change to the appropraite path where you copied input.doc object fileInput = @"C:\input.doc"; // Template file - change to the appropraite path where you copied input.doc object fileOutput = @"C:\output.doc"; // Open document Microsoft.Office.Interop.Word.Document docWord = appWord.Documents.Open(ref fileInput, ref mis, ref mis, ref mis, ref mis, ref mis, ref mis, ref mis, ref mis, ref mis, ref mis, ref mis, ref mis, ref mis, ref mis, ref mis); // Set bookmark name object bookmarkName = "MyBookmark"; // Get bookmark location Microsoft.Office.Interop.Word.Range bookmarkLocation = docWord.Bookmarks.get_Item(ref bookmarkName).Range; // Get barcode image Bitmap image = (Bitmap)barcode.GetImage(); // Copy image to the clipboard Clipboard.SetDataObject(image); // Paste barcode image to the document bookmarkLocation.Paste(); // Save to the new document docWord.SaveAs(ref fileOutput, ref mis, ref mis, ref mis, ref mis, ref mis, ref mis, ref mis, ref mis, ref mis, ref mis, ref mis, ref mis, ref mis, ref mis, ref mis); // We needn't save changes object saveChanges = false; // Close word application appWord.Quit(ref saveChanges, ref mis, ref mis); // Release COM object System.Runtime.InteropServices.Marshal.ReleaseComObject(appWord); } } }

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