The Word OLE VBNet sample is a simple Windows console application that converts a MS Word document (C:\Test.doc) to PDF using Word OLE automation.
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 11"
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 NovaPdfOptions11
pNova = New NovaPdfOptions11
Dim activeProfile As String = ""
Dim newProfileID As String = String.Empty
' initialize the NovaPdfOptions110 object
' if you have an application license for novaPDF SDK,
pNova.Initialize(PRINTER_NAME, "")
' save old active profile id
pNova.GetActiveProfile(activeProfile)
' create new profile
pNova.AddProfile(PROFILE_NAME, PROFILE_IS_PUBLIC, newProfileID)
'load the new profile
pNova.LoadProfile(newProfileID)
'and set some options
pNova.SetOptionString(NOVAPDF_INFO_SUBJECT, "C# Word OLE document")
pNova.SaveProfile()
'set the copy profile as active profile ...
pNova.SetActiveProfile(newProfileID)
'set nova default printer
pNova.SetDefaultPrinter()
' print word document
Dim objWord As Object
Dim objDoc As Object
pNova.InitializeOLEUsage("Word.Application")
objWord = CreateObject("Word.Application")
pNova.LicenseOLEServer()
objDoc = objWord.Documents.Open("C:\\temp\test.docx", False, True)
objDoc.PrintOut(False)
objDoc.Close(False)
objWord.Quit(False)
' restore active profile
If activeProfile.Length > 0 AndAlso activeProfile.CompareTo(PROFILE_NAME) <> 0 Then
pNova.SetActiveProfile(activeProfile)
pNova.DeleteProfile(newProfileID)
End If
' restore default printer
pNova.RestoreDefaultPrinter()
End Sub
End Module