Converting Office files to PDF using SaveAs - vb.net

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.

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

Extract embedded pdf from PowerPoint presentation using VBA or VSTO

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.

Open a .pdf file

I am trying to open a .pdf file within Excel like an iframe in HTML.
My requirement is:
Save the path of multiple PDF files in Excel.
Excel should open each .pdf file within Excel itself (no need to open that in a separate .pdf window).
It should be like iframe in HTML. The user should be able
to view the .pdf within Excel itself.
I know this is little weird, but can anybody help me?
you could probably get the filenames via vba.
here's some that claim to work:
Loop through files in a folder using VBA?
So far as opening a pdf in excel - thats kinda pushing it.
Since your request is exotic I can think of an exotic workaround:
If you can spare the interactivity you can simply make copies and convert your pdfs to word formats to work with them and load them in that way. I've seen people convert pdfs to Jpgs just to load them in some other documents but thats rudimentary and really fringe.
Otherwise you are facing a lot of custom coding that needs to make it possible.

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

MS Word SaveAs File Dialog with filters

I want to save a custom file from VBA code under Microsoft Word. Is there an appropriate SaveAs dialog in Word VBA? What I need from this dialog:
to specify a custom filter;
to select a file that (probably) does not exist;
use Word VBA only if possible.
Solutions I found on this site:
Application.FileDialog(msoFileDialogSaveAs). Doesn't allow to specify a custom filter.
Application.FileDialog(msoFileDialogFolderPicker). Doesn't allow to select a file that does not exists (this is a File Open dialog, not a File SaveAs one).
Application.GetSaveAsFilename. Works in Excel, but absent in Word.
Using Windows API. I want to avoid this if it is possible.
Calling an Excel application from Word VBA and use GetSaveAsFilename. Ugly solution. Is there any other way?
Is Word Interop an acceptable alternative to you ? If so you can use SaveAs of the Document class.