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? - vba

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

Related

Customize ribbons for every MS Word document

I am new to development with VBA. I am working on a project based on MS Word macros.
Lately, I have been trying to create ribbons to access certain functionalities, but I have got limited success in it.
I want to customize ribbons using XML which should appear on all MS Word files and not the one I have used to customize ribbon.
Is there any way to create any XML file that can be utilised by all MS word documents without having to customize each one of them.
Thanks..
Regards
The answer for this is essentially the same as for making macros available to all documents:
Store the Ribbon in a template (together with the macros, so a dotm) and load it as an Add-in.
If it should load automatically, that means placing it in Word's STARTUP folder.

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.

Creating read-only Microsoft Word file using VB.net

I am trying to create a Microsoft Word file in VB.net which is read only.
My aim is that user will input the data in a Windows form, after pressing export button it'll get exported to a Word document. But here's a twist: I want this Word file to be read only.
Is there any option to do this? I have tried exporting through Crystal Report, but its still editable.
Any help would be appreciated.
You can use the File.SetAttributes method for that, I think. Check the MSDN site.

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.

New document-button behave as the Transfer documents-button

In an ordinary document list in SharePoint 2010 there are two buttons for adding documents: “New document” and “Transfer documents”. New document usually opens a blank word document, and Transfer documents usually gives the possibility to choose a document to add to the list.
In a document library in our environment, the New document button opens the form to upload an existing file rather then open an empty word document.
Why does this happen? Is there a setting that specifies this behavior?
It happens when there are no default templates, possible due to custom content types with no set default document template (word, excel, etc) pherhaps due to upgrade from SP 2007 to 2010?
Quick fix: Add document template to the custom content type and add document should reappear.