How to print first page only of a message? - vba

Everything I found didn't work in version 2016 which I'm using.
I'm looking to print only the first page of the selected message.

Outlook Object Model does not give you much control over printing - MailItem.PrintOut is all you get. You'd be better off saving the message in the HTML or MHTML format, opening it in Word programmatically and printing it using Application.PrintOut (where Application is Word.Application).

Related

Mailitem.PrintOut() to PDF

I want to printout a complete email to pdf. the standard printer is selected as microsoft Print to PDF. Running the printout method, a saveas window occures and I dont know, how to handle that programatically.
I still know the way to convert via a word object, but that does not work, as screenshots will not be printed and the header is missing. So, this is not an answer for me: Save complete email, body and header, as PDF
Can anybody tell me how to deal with the saveas dialog and the filename of the resulting pdf?
One possibility would be to print the mail to an xps file (print to file - how to do that). After that, I could convert xps to pdf using PDFSharp.
Regards and thanks,
Jan
The Word editor can be used for saving the message body as a PDF file.
Word.Document doc = mailItem.GetInspector.WordEditor;
doc.SaveAs2(fullPath, FileFormat: Word.WdSaveFormat.wdFormatPDF);
Note, you need to add a COM reference to the Word object model to your project before using its object model in the code.

How to mimic the OneNote Page Group Print Range Functionality in VBA?

I am creating a process using VBA code, via a Microsoft 2013 Access database, to loop through Pages of a 2013/2016 OneNote notebooks, to print the Section’s Pages to pdf files.
I am using the Publish Method (oneNote.Publish pageID, publishContentTo, pfPDF) to print each Section Page, which requires only a single Page ID as the method’s first variable, thus only printing one Section Page per pdf file, whether it be a Page or Subpage.
The code works; however, I need to print the Sub Pages into the same pdf file of its Parent Page.
I know that OneNote has the functionality. If you click File, Print, then Print Preview, the user interface will bring up the Print Preview & Settings Dialog box. In that box, under Settings, there is a dropdown to pick a Print Range. When I select the Page Group range, and print the file, it includes the subpages along with the Parent Page.
Is there a VBA function to mimic printing of the Page Group range, or is there a way using the current Publish Method or any other VBA coding functions or methods?
This is the first time I am coding with OneNote and I am not finding many OneNote/VBA examples.

ActiveReports 7 Section Document Printing All Blank

I'm using ActiveReports 7 PRO and cannot get the reports to print correctly. It sends the document to the printer however it's all blank. I'm needing to print a bunch of reports in a loop so I'm looking to do this all programmatically. Here's the code I'm currently using after the DataSource is set, etc:
rptPT.Run(True)
rptPT.Document.Printer.Print()
I can't seem to load it into a viewer in the loop and print it that way (nor do I want to) because it tells me that the report has not been loaded fully. Like I said, it prints, however it's just a blank page with nothing on it. Also: if I export it to a PDF everything is fine in the PDF document.
Thanks!
Please refer to the following forum post wherein similar issue has been discussed and resolved :
http://our.componentone.com/groups/topic/printing-blank-pages-2/
See if this helps.
Regards,
Mohita

Convert Omniform to PDF in bulk/commandline

We have a large number of Omniform files (around 100,000). We're updating our main server OS from Windows Server 2003 to Windows Server 2008. Omniform isn't supported in Windows Server 2008 so we need to convert these files to pdf (or another viewable format).
What I've tried so far:
Using Print or PrintTo verb from inside a program using Process.StartInfo and using a PDF Writer printer.
Using Print directly from a command line using the Print verb with the PDF Writer set as the Default Printer:
C:\PROGRA~1\ScanSoft\OMNIFO~1.1\OmniForm.exe /p "Test.ofm"
Both of these Print successfully and a PDF appears. However it prints only the Form, not the Form with the entered in Data. Namely you'll get Last Name then a blank instead of showing the entered last name.
If I print to a normal printer and not a PDF Writer I get the same behavior. Form only with no entered in data appearing.
I've tried calling Nuance Tech Support and they suggested doing them manually 1 at a time. Given this would take someone about half a year of full time work to do, that's not a viable option for us.
So what I'm looking for is a solution to the command line print above
If an "image" of the filled-in form might work for you, Omniformat might help you out. It basically converts the file to pdf using a print-to-file method, but it might help you out, since it does batch conversion.

characters missing when printing

We have a WPF application which can perform either a report preview or a report print.
Both requests use the same code.
Call the report service which gets the report from Microsoft Report Services.
Convert the report into the desired format (in this case PDF).
Then return the report as a byte array.
The result is then written to a temporary file as a binary stream, and either popped into a window to preview or start a Process to print.
In both cases the temporary file is passed.
Print Preview works flawlessly! But Print Report will print with all occurances of 'ti' disappearing. I see there is a printer escape sequence of ESC t NUL/SOH and I assume that if, for some reason, an escape character gets into that stream that ti will result in an ignored print sequence. Thus the missing characters.
My first question is if anyone has ever experienced this with generated PDF reports?
My second question (obviously) is if anyone knows of a utility I can use to view the binary data in the file being printed, to see what is in the file just before every 'ti' sequence?
After a great deal of searching I came across a post on the Adobe forum that states that version 8 had a bug where it was not printing character combinations. Once I dug deeper it seems that it has returned and the suggested workaround fixed our issue.
Workaround: Do a print as image.
Adobe seems to be unable to do the most basic of what their software must do, print the exact content!
Answer for your second question:
First, do one of the following two things:
Set the Windows print spooler properties to not delete printed jobs.
Pause the target print queue.
Then, grab the spool file from the Windows printspool directory (which location that is you can find out by looking at the (right-click) 'Properties...' dialog of the 'Printers and Faxes' folder).
I realize this is an old post but I wanted to add some updated info from the above comment stating that it's a problem with Acrobat 8. We are using Acrobat 10.1.6 and still have the same problem. From what I've read, it's a problem with the adobe product itself. The only real fix I've seen (actually work around) is to print as an image. LAME
Surprisingly this bug is still there in 2021. Adobe cannot be relied upon printing documents properly. This takes away all the allure of features it had if it cannot do the most basic stuff it is required for.
Printing as image reduces the quality and blur the document.
Simply open the document with Safari or Chrome and print from there. E
I had a similar problem while printing directly from the firefox (acrobat reader within). I downloaded the file and then printed. The problem was solved.