Link to home
Create AccountLog in
Avatar of Luis Diaz
Luis DiazFlag for Colombia

asked on

VBA PowerPoint: Unable to use a potm file as reference everytime that I open PowerPoint file.

Hello experts,


I would like to save a PowerPoint template to use everytime when I open a PowerPoint.

I tried to save template file as:  pptm and potm and it doesn't work. I have a personal PowerPoint add-in.


Thank you for your help.


Avatar of ste5an
ste5an
Flag of Germany image

When your file is loaded, right-click on the theme in the design tab. There is "Set as default" option.
Avatar of Luis Diaz

ASKER

Noted. Not necessary to save the file with an specific extension?

Ste5an's suggestion will work if you need the File>New option to create a new presentation from your template.


Perhaps you need this file to open automatically when you open PowerPoint, so you can edit or reference the actual template. If so, create a new .pptm file, add this code, save the pptm, then save as to another add-in. After installing that add-in, the presentation or template referenced in the third line of Auto_Open will open automatically. If you double-click on a different file to open it, your template will open in the background, so the macros are still available. Depending on the speed of your system, you may not need the Wait (1) line to slow down the code:


Private Declare PtrSafe Function WaitMessage Lib "user32" () As Long
Sub Auto_Open()     Dim oPres As Presentation     Set oPres = Presentations.Open(FileName:="Y:\Add-ins\PowerPoint VBA.pptm")     Wait (1)     If Application.Windows.Count > 1 Then         oPres.Windows(1).WindowState = ppWindowMinimized     End If End Sub Sub Wait(Seconds As Double)     Dim endtime As Double     endtime = DateTime.Timer + Seconds     Do         WaitMessage         DoEvents     Loop While DateTime.Timer < endtime End Sub

Open in new window


ASKER CERTIFIED SOLUTION
Avatar of Jamie Garroch (MVP)
Jamie Garroch (MVP)
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
It works!
Thank you very much!
@Jamie Garroch (MVP): last question. How can I avoid the following message:
User generated image

Macro security in Office is a huge topic. In our commercial products we sign our VBA code and installer apps with an EV (Extended Validation) code-signing certificate, which is expensive and difficult to purchase. That certificate then needs to be added to the trusted store during the app installation. If you are installing for internal users only, you could simply change the security settings in the PowerPoint app but this exposes those machines to other malicious code. It's not a simple one to solve. The setting you could try is in File / Options / Trust Center / Trust Center Settings / VBA / Macro Settings:


User generated image


Note that you don't need the Developer Macro Settings part unless you are using VBE Extensibility to programmatically change code.

You should also make sure the add-in has been installed in a trusted location.

Note too that depending on how you distribute your project, you may come across "MOTW". I explained that in this article and got around it by doing this.


Finally, note that if you see that error dialog twice in succession, it means that there is a problem with a customUI callback. Microsoft are notorious for providing the same misleading message for multiple conditions!

Ok, now it works! Thank you very much!