Limited time promo

Word OLE VBNet - SDK sample

English en

This article applies only to novaPDF. If you don't have it yet, you must download it first.

Download now Buy licenses
Feb 25, 2019

We strive to keep our articles as accurate as possible. If you notice any inconsistencies or outdated info please let us know.
Sample VBNet app that converts a MS Word document to PDF using OLE Automation.
Word OLE VBNet sample is a simple Microsoft Windows console application that converts a Microsoft Word document (an example path for the document would be *C:\Test.docx*) to a PDF using Word OLE automation and the novaPDF SDK application.
Note: To be able to use the samples you must install novaPDF SDK as samples work only with it. Download it here: nova PDF SDK.

Source Code
Imports System
Imports System.Drawing
Imports System.Drawing.Printing
Imports System.Windows.Forms
Imports novapiLib80

Module Module1
	'    <summary>
	'    The    main entry point for the application.
	'    </summary>
	Const PRINTER_NAME As String = "novaPDF SDK 8"
	Const PROFILE_NAME As String = "Word OLE VBNet"
	Const PROFILE_IS_PUBLIC As Integer = 0
	Const NOVAPDF_INFO_SUBJECT As Integer = 68

	Sub Main()

		' create the NovaPdfOptions80 object
		Dim pNova As NovaPdfOptions80
		pNova = New NovaPdfOptions80
		Dim activeProfile As String = ""
		Dim newProfileID As String = String.Empty

		' initialize the NovaPdfOptions80 object
		' if you have an application license for novaPDF SDK, 
		pNova.Initialize(PRINTER_NAME, "")
		' save old active profile id
		' create new profile
		pNova.AddProfile(PROFILE_NAME, PROFILE_IS_PUBLIC, newProfileID)
		'load the new profile
		'and set some  options
		pNova.SetOptionString(NOVAPDF_INFO_SUBJECT, "C# Word OLE document")
		'set the copy  profile as active profile ...
		'set nova default printer
		' print word document
		Dim objWord As Object
		Dim objDoc As Object
		objWord = CreateObject("Word.Application")
		objDoc = objWord.Documents.Open("C:\temp\test.docx", False, True)

		' restore active profile
		If activeProfile.Length > 0 AndAlso activeProfile.CompareTo(PROFILE_NAME) <> 0 Then
		End If

		' restore default printer
	End Sub
End Module