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

Download now Buy licenses
Adrian (Softland)
Mar 29, 2022
novaPDF 11.x
We strive to keep our help as accurate as possible. If you notice any inconsistencies or outdated info please let us know.
The Convert Office Docs sample is a simple Windows console application that converts some Microsoft Office documents (Word, Excel, Publisher, PowerPoint and Visio) using Convert... functions. It uses Office OLE automation so Microsoft Office has to be installed.
The sample documents converted are located in the "OfficeDocuments" folder in novaPDF SDK installation folder. The pdf files are saved in the same folder.
Hidden links and internal document links are converted in pdf hyperlinks (except for Excel documents).

Source code

Imports System
Imports System.Windows.Forms
' the novapiLib package must be added as a COM reference
Imports novapiLib11

Module Module1
    '    <summary>
    '    The    main entry point for the application.
    '    </summary>
    Const PRINTER_NAME As String = "novaPDF SDK 11"
    Const PROFILE_NAME As String = "ConvertOffice"
    Const PROFILE_IS_PUBLIC As Integer = 0
    Const NV_PROFILE_EXISTS As Long = -707133434

    Sub Main()
        Try
        ' create the NovaPdfOptions object
            Dim pNova As NovaPdfOptions11
            pNova = New NovaPdfOptions11
        ' initialize the NovaPdfOptions object
        ' if you have an application license for novaPDF SDK, 
            ' pass the license key to the Initialize() function
            pNova.Initialize(PRINTER_NAME, "")
        ' mark start changing options
        ' get the active profile ...
            Dim activeProfile As String = ""
            Dim nActivePublic As Integer = 0
        Try
            pNova.GetActiveProfile(activeProfile)
        Catch ex As System.Runtime.InteropServices.COMException
            ' ignore profile exists error
            If (NovaErrors.NV_NO_ACTIVE_PROFILE = ex.ErrorCode) Then
                System.Console.WriteLine("The printer does not have an active profile")
            Else
                'more   serious error, propagate it
                Throw ex
            End If
        End Try

        Dim newProfileID As String = ""
        Try
            ' and make    a copy of it
            pNova.AddProfile(PROFILE_NAME, PROFILE_IS_PUBLIC, newProfileID)
        Catch e As System.Runtime.InteropServices.COMException
            ' ignore profile exists error
            If (NV_PROFILE_EXISTS = e.ErrorCode) Then
                System.Console.WriteLine("Profile already exists")
            Else
                ' more    serious    error, propagate it
                Throw e
            End If
        End Try

            'load the new profile
            pNova.LoadProfile(newProfileID)
            'nova.NovaTools.AddProfileOptions(pNova);

            ' and set some  options
            ' uncomment the function calls for the options you wish to set

            ' DO NOT OPEN PDF 
            ' an Open action is added by default in the profile - delete or disable this open action
            ' pNova.DisableActionType(ActionType.NOVA_ACTION_OPEN)

            ' change the sav options
            NovaTools.AddSaveOptions(pNova)

            'save the new added profile
            pNova.SaveProfile()
            ' set the copy    profile    as active profile ...
            pNova.SetActiveProfile(newProfileID)


            'Path for novaPDF 11 SDK sample documents
            Dim strDocumentsPath As String = "C:\Users\Public\Documents\novaPDF 11\SDK\OfficeDocuments\"
            Dim strDocPath As String

            ' --------------------------------------------------
            ' Convert Word document
            ' Microsoft Office Word has to be installed
            ' --------------------------------------------------
            'Document file path
            strDocPath = strDocumentsPath + "Word.docx"
            'style name | level | type 
            Dim strHeadings As String = "Heading 1|1|0;Heading 2|2|0;Heading 3|3|0"
            pNova.LicenseApplication("WINWORD.EXE")
            pNova.LicenseApplication("SPLWOW64.EXE")
            pNova.ConvertWordDocument(strDocPath, 1, 0, 1, 1, 1, 1, 1, 1, 1, 3, strHeadings)

            ' --------------------------------------------------
            ' Convert PowerPoint document
            ' Microsoft Office PowerPoint has to be installed
            ' --------------------------------------------------
            'Document file path
            strDocPath = strDocumentsPath + "PowerPoint.pptx"
            pNova.LicenseApplication("POWERPNT.EXE")
            pNova.LicenseApplication("SPLWOW64.EXE")
            pNova.ConvertPowerPointDocument(strDocPath, 1, 1, 1, 1, 1, 1)

            ' --------------------------------------------------
            ' Convert Publisher document
            ' Microsoft Office Publisher has to be installed
            ' --------------------------------------------------
            'Document file path
            strDocPath = strDocumentsPath + "Publisher.pub"
            pNova.LicenseApplication("MSPUB.EXE")
            pNova.LicenseApplication("SPLWOW64.EXE")
            pNova.ConvertPublisherDocument(strDocPath, 1, 1, 1, 1, 1, 1)

            ' --------------------------------------------------
            ' Convert Excel document
            ' Microsoft Office Excel has to be installed
            ' hidden links in Excel documents will not be converted to pdf links
            ' --------------------------------------------------
            'Document file path
            strDocPath = strDocumentsPath + "Excel.xlsx"
            pNova.LicenseApplication("EXCEL.EXE")
            pNova.LicenseApplication("SPLWOW64.EXE")
            pNova.ConvertExcelDocument(strDocPath, 1)

            ' --------------------------------------------------
            ' Convert Visio document
            ' Microsoft Office Visio has to be installed
            ' --------------------------------------------------
            'Document file path
            strDocPath = strDocumentsPath + "Visio.vsd"
            pNova.LicenseApplication("VISIO.EXE")
            pNova.LicenseApplication("SPLWOW64.EXE")
            pNova.ConvertVisioDocument(strDocPath, 1, 1, 1, 1, 1)

            pNova.SetActiveProfile(activeProfile)
            pNova.DeleteProfile(newProfileID)
        Catch e As System.Runtime.InteropServices.COMException
            MessageBox.Show(e.Message)
        Catch e As Exception
            MessageBox.Show(e.Message)
        End Try
    End Sub
End Module