Dim returnedStatusCode 'This is the variable that will hold the status of pdf conversion outputDirectoryForPrintedPdf = Reporter.ReportPath & "\PdfDocs" 'This is where the pdf would be generated; You can change this to suit your needs. temporaryCacheFolder = Reporter.ReportPath & "\PdfCache" 'This cache will be deleted at the end of conversion but can also be kept through the switch -ClearCacheFinally False. You can change this to suit your needs. nameOfPdfFile = Environment("ActionName") 'This will be the name of the pdf file generated under the folder:outputPathForPrintedPdf. You can change this to suit your needs. pathToConversionUtil = "D:\OneNote2PDF\OneNote2PDF\bin\Debug\OneNote2PDF.exe" 'You have to specify the path where you have placed the executable in your machine.. Set oShell = CreateObject("Wscript.Shell") 'Let's get the shell object to run OneNote2PDF command-line utility. O' Shell, come to my rescue! ' Capture the current time before proceeding to print completeDate = year(Date) & "-" & month(Date) & "-" & day(Date) lastPrintedTime = completeDate & " " & Time 'Since we need the lasprintedtime to be our lower limit for pages, give the print command to the application here AFTER we have captured the current time. msgbox "Modify the script here to call the action that prints pages through the application!" ' Actually run the command-line utility in the background and wait for the utility to return a code. ' ClearCacheFinally switch deletes the cache files generated during conversion at the end. ' Output switch determines where the final merged pdf would be placed ' CacheFolder is just a temporary location to hold various pages in the Unfiled Notes section ' PagesAfterThisTime tells the program to look for only those pages which were printed after the specified time ' ShowTOC makes sure that the pdf is not cluttered with a Table Of Contents if you specify it as false returnedStatusCode = oShell.Run("""" & pathToConversionUtil & """" & " -NameOfPdfFile " & """" & nameOfPdfFile &"""" & " -ClearCacheFinally True -Output " & """" & outputDirectoryForPrintedPdf & """" & " -CacheFolder " & """" & temporaryCacheFolder &"""" & " -PagesAfterThisTime " & """" & lastPrintedTime &"""" & " -ShowTOC False -RefreshCache True", 0, True) ' I have hardcoded 0 to mean Success If returnedStatusCode = 0 Then fullPathToPdf = outputDirectoryForPrintedPdf & "\" & nameOfPdfFile & ".pdf" ' Okay, now, we have a pdf at the location contained in fullPathToPdf variable ' Let's open the pdf. ' Now, if you have Adobe Acrobat Standard or Professional on your machine, then you can use the ActiveX approach, which is more robust. ' I just have Adobe Reader X so I've used the another way. It will just show the pdf on screen. Feel free to modify this according to your needs. pdfViewResult = oShell.Run("acrord32.exe " & fullPathToPdf, 1, True) ' This one manual step is actually hurting me! More information needed to improve this... testerChoice = MsgBox("Was the PDFOkay?", vbYesNo, "Pdf Verification") If testerChoice = vbYes And pdfViewResult = 1 Then Reporter.ReportEvent micPass, "CheckingPrintedPages", "The pages printed are fine and a pdf is available @ " & fullPathToPdf Else Reporter.ReportEvent micFail, "CheckingPrintedPages", "The application's Print functionality has a problem. Pdf available @ " & fullPathToPdf End If End If ' I have modified the command-line utility to return various codes in case of error ' -1 means Could not obtain reference to OneNote ' -2 means The file Unfiled Notes.one does not exist, which in our case will mean that no prints were received by the OneNote Printer Driver. This is so ' because even if the file does not exist, OneNote regenerates it every time it receives a print request. '-3 means that the OneNote couldn't return the OneNote Xml for the notebook we're interested in. Basically, this means that there was some problem with OneNote. '9 means that an unknown error occurred. ' -99 means that there were no pages printed after the date time we specified. If returnedStatusCode = -2 Or returnedStatusCode = -99 Then Reporter.ReportEvent micFail, "CheckingPrintedPages", "No pages were printed by the application" Else If returnedStatusCode = -1 Or returnedStatusCode = -3 Or returnedStatusCode = -9 Then Reporter.ReportEvent micFail, "CheckingPrintedPages", "There was a problem accessing the OneNote Application" End If End If