Changing advanced options in PowerPoint with VBScript - vba

I am writing a VBS script which copies chosen pictures from the folder where the script is placed to newly created PowerPoint document, adds some comments to each slide and saves the document in the same directory. The problem that I'm facing is a size of .pptx file which very often exceeds 500MB.
PowerPoint (2013) has built-in option to "Discard editing data" in Advanced Option menu which lowers the resolution of all images in the document to wish value (220 ppi in my case).
Is there an option to access related checkbox with VBSript? I was searching hard to find information how to enable this option via scripting but haven't found anything useful.
I would be much grateful for your help!

This isn't something that's accessible via the PPT object model, but since you're using VBS and not VBA from within PPT, you can probably make a few registry settings before launching PowerPoint.
To work out the needed settings, open REGEDIT and navigate to
HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\PowerPoint\Options
Note: 15.0 is the version to use for PPT 2013. PPT 2016 is 16.0, 2010 is 14.0 and so on, skipping 13.0
Leave REGEDIT open while you change the PPT settings you're after; after each change, switch to REGEDIT and hit F5 to refresh. Any settings that change or are newly added are the ones you're after.
To get you started, the setting for automatically compressing pictures is a DWORD:
AutomaticPictureCompressionDefault

Related

How to save Visio macro as add-in

I wrote a macro in Visio, but noticed that I cannot add it to the quick-access toolbar. I assigned it to a keyboard shortcut, and I'd like to make it available in any Visio file which is opened.
With Word I just saved my macros as word add-ins, and made them available as global templates, however in Visio the options only show COM add-ins.
How can I make my macro available in every Visio file opened?
You can't do this in Visio. A work-around is to save the macro into a stencil (you have to save the stencil in .vssm format) then if you always have this stencil open then the macro(s) will be available.

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

How do I create a Word VBA personal VBA code library as I have done in Microsoft Excel..?

How do I create a Word VBA personal code library as I have done in Microsoft Excel..? I had this working, but today it broke and I cannot make it work again. I originally did this because my Normal.dot file blew up and I lost all my macros. I found a blog post that described how to do it, but I cannot find my way back there. I've Google this extensively, but not found a solution.
There are some twists & turns here, as described below...
In Microsoft Excel, one can easily create a "code library project". This is simply a standard XLSB file with VBA modules in it, saved in the ..\Excel\STARTUP folder alongside the PERSONAL.XLSB file.
When the VBA editor is open in any other XLSX/B file, the modules in the code library file are always visible. And thre's not a requirement to create a VBA project reference to see them. The library modules can be natively edited as if they were an integral part of any other file, without requiring the library file to be open in another window to do so, as shown in the picture...
However...in Microsoft Word, it seems to work differently, and...strangely. If the same is done: create a DOCM file with custom code modules, and save it in the ..\Word\Startup\ folder, those modules are not visible in the VBA Project Explorer.
Following along the chain of logic from Excel to Word, and do as others have done...save the DOCM as a DOTM instead, and save it in the ..\Templates folder with the Normal.dotm file. Still, it is not visible in Project Explorer.
It's not until Normal.dotm is opened for editing and the library DOTM is added as a VBA Project Reference that it finally appears in the Project Explorer, but only while Normal is open. Plus...it opens the code library file for editing in another window..! If Normal is saved with that reference, and a new document is created from it, the library code cannot be edited and displays the error "project is unviewable"...
It's not until the library DOTM file is opened for editing in a second window that it's code becomes editable, and it does so in all Word VBA windows on all documents at the same time.
There is one glimmer of hope: if I create a new blank DOC from the library DOTM instead of Normal.DOTM, it works..! Any document created from the library retains a link to the code modules there, including any new or edited ones, and they can be edited natively right there in the Project Explorer. And this includes the code modules in Normal.DOTM too.
It seems the "editability" is one way: documents created from any other template can see & edit both their own code and those in Normal.DOTM, but not the other way around: documents created from Normal.DOTM can only see their own code.
How can this connection be made two-way for all documents, regardless of what template they were created from..??
I've been trying to wrap my head around the possibility it may be a security/malware issue, but I can't come up with one. If macros are already enabled in the Trust settings, malware is already 99% on the way to controlling a machine anyways. The only step left is enabling VBIDE.
A very similar question on Microsoft Answers:
Is there a startup or template file in Words that allows one to store "personal macros", i.e. macros that one wants to have always available while editing documents (I am seeking the equivalent to the PERSONAL.XLSB file in Excel, where I can store macros that then are available in all sheets that I open).
And the solution given:
Word uses the default template Normal.dotm for this purpose. Macros stored in Normal.dotm will be available in all documents. Apart from that, Normal.dotm also serves as the default document template, and it also stores the user's formatted AutoCorrect entries.
Just like Personal.xlsb, Normal.dotm doesn't exist in a clean new installation, but it will be created when needed.
The location for Normal.dotm is
C:\Users\<username>\AppData\Roaming\Microsoft\Templates
AppData is a hidden folder, so you must display hidden files and folders in order to see it in Windows Explorer.
Similar questions (also on answers.microsoft.com) have been offered same type of solution.
Macros that should be globally available can be stored in Normal.dotm or in a template located in the Startup folder for Word. See also:
And:
In Word, personal settings (those that aren't stored in the Registry) are stored in the Normal template, Normal.dotm. When you change and save settings or create macros, they are automatically saved in Normal.dotm unless you choose to save them in another template. Normal.dotm is automatically loaded when you start Word, and new Blank Documents are based on Normal.dotm.

Editing the ribbon of an existing Power Point Add-In (to fix display error)

I have been asked to remedy a display error of an already existing Power Point Add-In (error occurs when moving from Office 2007 to Office 365)
See picture below
I need to get rid of the parts highlighted by the red boxes.
Primary question: How do I open the add-in-file (I have the original .pptm file) so that I can edit how the ribbon is displayed?
My Background: I know VBA very well but have never done XML-development of the ribbon before.
A pptm file uses the Open Packaging conventions of the Office Open XML specification. Open the pptm with WinZip or 7-zip, or rename the .pptm to .zip, and browse the contents. You should find a file within the zip-file called something like CustomUI.xml or CustomUI14.xml, although the exact name can be anything, and will be specified in the .rels file in the root of the file (there can be 2 files, one for Office 2007 and later ribbons, and one for Office 2010 and later, in which case the 2007 version is ignored in 2010 and later).
Once you've found the file, extract a copy, make your edits in any text editor, and then copy the file back into the pptm, replacing the existing ribbon customization file.
Then load the pptm, and check your changes were successful.
PowerPoint add-ins don't show their code in the VBE, by default, although macro-enabled presentations do. If it is an add-in, you may need to tweak the registry in order for the add-in project to display. See this article for details: How To View Your PowerPoint Add-in VBA Code Inside The Visual Basic Editor

can we run/install macro in without macro enabled files (pptx)?

I wrote some macro of PowerPoint. Now if I want to run these macros, I need to save my PowerPoint as pptm file. It is kind of matter, as I need to save the final file as pptx not pptm. Is there any way, I can install or run my macro to pptx files? I mean could I install my macro as an add-in, and it is working in pptx file.
If the way works, I can save my macro template powerpoint as pptx,
that is easier and more convenient.
Thanks,
You could create an application add-in which would allow the Public procedures within it to be available independently of the PowerPoint file(s) you are working on in any given session. You could optionally add controls to a custom ribbon tab by editing the fluent UI XML of the file (I have some articles on Stack Exchange to show you how) and link those to your macros.
To create an add-in, save the .pptm file as a .ppam file (the folder location will change accordingly). Then in PowerPoint, assuming you have the Developer tab enabled, you can click Add-Ins and load your add-in from there. If the Developer tab isn't enabled, you need to go into the Backstage by clicking File then Options to add add-is.
To make sure the add-in loads automatically each time PowerPoint starts you can add code to the Auto_Open macro to add the two relevent registry keys (add-in Path and AutoLoad flag) or do this manually using regedit.exe. If you are deploying to many machines, the add-in can be wrapped in a setup.exe or setup.msi package but that is another topic.
No I don't think so there is anyway to run macro without enabling it.
But Alternate solution can be to.
Save the main file as .pptx and you can have another file as .pptm you just need to add sub to open the .pptx or main file and perform the macro fuctions from there
In this way your macros file and .pptx are seperate and you can achieve what you are trying to do via the .pptm files.
Hope this helps.