Extract embedded pdf from PowerPoint presentation using VBA or VSTO - vba

I need to extract embedded (without links) pdf documents in PowerPoint file. I can extract embedded files from Excel using ActiveSheet.OLEObjects and checking for ProgID. Then I copy it to clipboard and save as described here
But for some reason I could not find equivalent to Excel.OleObject in PowerPoint. The closest thing I think is shape.OLEFormat.Object property but it does not support Copy method. I checked this but if it is possible I need a VBA solution.

What you need to do is open the embedded PDF using DoVerb:
ActivePresentation.Slides(1).Shapes(1).OLEFormat.DoVerb
going from there you are depending on your installed software to either address saving the file using SendKeys or if available an API on Adobe Reader.
For a full discussion on this read the thread on the MSDN Forums here:
https://social.msdn.microsoft.com/Forums/en-US/235dde1a-13bb-4f07-8eb4-04ef1121a747/export-a-pdf-file-from-powerpoint-with-vba?forum=officegeneral

I accidently noticed that copying the PowerPoint shape itself does the job.

Related

How to use VBA to change the default MS Word 2016 options so that when you save as PDF the headings are included as bookmarks?

I'm using Microsoft Word 2016 and looking for a way to run a vba macro that will change the default option to Create bookmarks using: Headings when I save a document as PDF when I click on
File ->
Save As ->
PDF (*.pdf) ->
More options.. ->
Options
Note: The option is only available if you have a table of contents in the document.
The goal is that if a user chooses to save as PDF that option will be already checked.
I'm not asking how to do this manually, like in this question
nor programmaticaly save to PDF using vba like here or here.
Since it's not reachable by VBA at the point of save a file as PDF I do not see it as possible to change that PDF saving option using only VBA.
The only way I see you can reach the behavior you seek is as follow but need some special effort. You need to either create a VTSO addin or be able to have an extra marco file in the Microsoft Word Startup-Path so it will be loaded at Microsoft Word Startup.
Re-implement your own "Save" behavior by overriding the Save functionality (BeforeSave) of Microsoft Word and provide it via your own Save-Button in the Microsoft Word-Menu described here

Creating a pdf using Word VBA and Adobe Acrobat

I am trying to write a macro that creates a pdf of a Word document.
The code I have been using to do this uses ActiveDocument.ExportAsFixedFormat. This works up to a point, but it tends to fail when creating a pdf of a large document (and some of the documents I'll be processing with this macro run to thousands of pages).
My understanding is that the ExportAsFixedFormat method uses Word's built-in PDF creation methods. What I really want to do is use Adobe Acrobat to do the PDF conversion. If I do that manually by clicking on the export as pdf buttons within Word (I have Adobe Acrobat installed on my machine) then everything is fine. It uses the actual Adobe Acrobat PDF conversion, and my PDF gets created without errors even on documents large enough to cause the ExportAsFixedFormat method to fail.
I've been trying to figure out how to automate the conversion to PDF from VBA using Acrobat, and banging my head against a brick wall.
I discovered the CreatePDFEx method, which in theory looks like it should do what I want, but I also discovered warnings that this is not a supported method and is not recommended. See here:
https://forums.adobe.com/thread/286431
And indeed when I tried it, it didn't work.
I then discovered the AcroExch.AVDoc and AcroExch.PDDoc objects, which looked like it might be another way. See, for example, here:
https://forums.adobe.com/thread/301714
That also came with a warning that it wasn't supported. When I tried it, it worked, but it was painfully slow, even with documents of just a few pages. I hate to think what it would be like with a 5000 page document.
Is it actually possible to do this? It doesn't seem like it should be rocket science, but I am failing to find anything that works.
All I want to be able to do is to reliably create pdfs from large Word docs. I think that probably the way to do that is to figure out how to use Adobe's tools via VBA (is there a supported method?), but I'd be perfectly happy with the built in Word method if I could solve the problem of it failing with large documents.
Many thanks for any help.
Edit: I should also have mentioned that I need my Word headings to end up as PDF bookmarks. The ExportAsFixedFormat method does that, but some other methods don't.
You can use the SaveAs or SaveAs2 method to save as a PDF instead of ExportAsFixedFormat. For example:
ActiveDocument.SaveAs FileName:="Filename.pdf", FileFormat:=wdFormatPDF
On a bit more playing around, I did come up with one method which is an official supported method and uses the Adobe PDF creator:
ActivePrinter = "Adobe PDF"
ActiveDocument.PrintOut
The problem with that is that it doesn't turn my Word headings into PDF bookmarks.
Does anyone know if it's possible to set some options in that code so that it does?

docx4j word/googledocs compatibility

I'm creating a program which extracts a docx file, displays it in a Javafx graphic interface with buttons in place of flags put in the docx, and when one puts on it, it modifies the docx taken in input.
I'm using the docx4j API for extracting and modifying the document.
The problem is that the program fails if i take in entry a docx generated from Microsoft Word. I'm forced to use an artifice.
I'm taking my docx made on Word, then i load it in Google Docs and I use the "Download in .docx format" option. If i directly put the docx from Word in my program, it fails.
I noticed my Word file was two times lighter after being passed trough google doc. Same, if I tale a docx file downloaded from Google Docs, if i open it in Word and modify one letter and save it, he becomes two times heavier. For the record i use word 2008.
That's it, so I'd like to know if someone know what explains this difference.
Thanks

Converting Office files to PDF using SaveAs

I have a question about saving the Microsoft Office format file like doc, xls to PDF. I am using the SavesAs option in VB.Net to convert the files to PDF programatically. However, I need to open the file differently to achieve this.
If file is an Excel, then I need to open it using excel API's and then perform SaveAs. Similarly with Word documents. Is there a way so that I can open this documents generically and then use SaveAs option to convert them to PDF irrespective of opening the files?
The Word API and Excel API are two distinct APIs, even though they may both have a SaveAs method. You will not be able to use the same call for both file types.

How can I open, edit and save an MS-Word document programmatically?

I want to make a word editor for IOS in which I can open MS-Word documents and edit them like in MS Office and after that I can save the document. Can anyone help? I couldn't find any helping code. I tried to find the SDK forms-office but that is not available. I have tried google sdk for text documents which is DrEdit https://github.com/googledrive/dredit
Open Office can read and write MS-Word Documents, and their code is open. Probably hard to find the right passages, but better that reverse engineering the format yourself.
The code is here:
http://openoffice.apache.org/downloads.html
You can try with ThatPDF . Its basically for annotation of PDF but you can customise it for word documents. Here is the Github link for the open source project.