Remove Add-in in Powerpoint with VBA - vba

I have a VBA Add-in in PowerPoint that is updated occassionally. I wrote a code in VBA where every Monday there is a check wether a newer version of the Add-in exists. And if it does, PowerPoint automatically updates the Add-In. So far, I have this accomplished:
Deactivate the old Add-In in PowerPoint
Delete the old Add-in in Microsoft's Add-In folder
Copy the new Add-In to Microsoft's Add-In folder
Activate the new Add-in in PowerPoint
However, I can't seem to find the right command to delete the old Add-in in PowerPoint. The old Add-in is still in PowerPoint's available Add-ins, and PowerPoint also lists it under the inactive Application Add-ins.
Here's part of the Code that first deactivates the Add-in, and then tries to remove it from PowerPoint.
Dim oAddin As AddIn
For Each oAddin In Application.AddIns
If Left(oAddin.name, 16) = "PPT ACO Add-in V" Then
oAddin.Loaded = msoFalse
Kill (oAddin) '<-- these is the line of Code that doesn't execute
End if
Next oAddin
The program would work, but after some time I'd have a bunch of inactive Add-ins laying around in PowerPoint which will be very confusing to users.
Thank you so much for your help guys.
Tommy

very late answer, but since I passed by and I spent myself quite sometime on this issue, instead of
kill (oAddin)
you need
kill oAddin.fullname
although you should also remove the addin from the collection of AddIns and maybe unregister.
Also, in version 2010, you might get an error of permission denied when you try to delete the file. This is caused by ppt not releasing in time the open addin file. In fact, a timer does not solve it. But a second kill will actually work.

Related

Recover code modules from corrupt vba pptm file

I opened my .pptm ppt vba macro source file for editing, it showed this dialog a few times.
once I open alt+F11 to VBA editor, it has all the forms but the underlying code is not opening, also the modules are unresponsive.
Can anybody suggest a way to recover code/modules from this corrupt file. I have the latest .ppam addin output, I can share the corrupted .pptm file if there is way to attach here. Thanks for the help folks!
Tossing this in as an answer as well as the comment. Better formatting!
Make sure PowerPoint is NOT running, then open REGEDIT.
Go to HKCU\Software\Microsoft\Office\xx.0\PowerPoint\Options
Replace xx.0 with your PPT version: 16.0 for 2016/2019/365, 15.0 for 2013, 14.0 for 2010 etc.
12.0 is 2007. There's no 13.0; MS is apparently superstitious.
Rightclick Options and choose New, DWORD Value
Name it: DebugAddins
Doubleclick it and change its value to 1
Close Regedit.
Start PowerPoint and open the VBA IDE.
All of your installed VBA addins will appear as projects that you can open and edit, so long as they're not password protected (and if you know the password, you're good to go).
Note that you cannot SAVE your edited code. You'll need to copy/paste it back into a PPT/PPTM file and save that, or export the modules you've edited and import them into the original PPT/PPTM.
You can generally have both the source PPT/PPTM and the addin code loaded in the IDE; just be sure you stay aware of which is which.

After I save VBAProject.OTM and restart Outlook, macros can't work; the ribbon is greyed out

I'm using a few VBA macros in Outlook 2013 Professional Plus in Windows 7 Family Version. After a windows crash, my macro in outlook can't work.
ALT+F11 open VBA editor, find all ribbons are grayed out, no project in Project window. can't edit VBA in editor.
close outlook, delete %userprofile%\AppData\Roaming\Microsoft\Outlook\VBAProject.OTM, then restart outlook
ribbons are back to live, "Project1" show up in project window, i can insert new module and edit VBA and save macro.
after save, close outlook, confirm the new "VBAProject.OTM" is created with right time stamp.
restart outlook, back to 1, all ribbon grayed out, can't find macro/project, can't edit VBA.
I've checked with Google, but can't find similar issue or answers.
tried delete office and reinstall, still not working.
Some article mentioned (Digital Certificate for VBA Projects and Visual Basic for Applications), both are installed.
appreciate if you could provide some input.
thx a lot.
Some screen prints below:
All ribbons grayed out, can't load or edit VBA
Delete VBAProject.OTM then restart outlook

One line PPAM add-in causes PowerPoint 2013 to crash

I have a user with a brand new machine with Win 7 x64 SP1 (6.1.7601), downgraded from Win 8, on it plus Office 365 Small Business Premium with PowerPoint 2013 32 bit (15.0.4649.1000).
I am debugging a PPAM add-in and have narrowed it down to a very bizarre situation I've never seen before:
Create a new PowerPoint file
Open the VBE, insert a module and add a one line sub as below
Save it as a PPAM
Load the PPAM add-in and see the message
Close PowerPoint
Open PowerPoint and it crashes with the message "Microsoft PowerPoint has stopped working" and the sub-text "A problem caused the program to stop working correctly. Windows will close the program and notify you if a solution is available."
I kill PowerPoint and when running again am asked the usual question if I want to disable the "offending" add-in
What on earth can cause such behaviour? No other PPAM add-ins are running and I have tried with all COM add-ins disabled and with running powerpnt /safe
My one line test sub inside the PPAM:
Sub Auto_Open()
MsgBox "It works"
End Sub
Btw, the full (and very complex) add-in works perfectly when loaded in its source PPTM form.
Badly written COM add-ins can cause this kind of thing, where PPT crashes at shutdown or startup and points the Fickle Finger of Blame at whatever PPA/PPAM add-in is closest at the time.
I'd have them disable any COM add-ins other than the MS-supplied ones, which I've never run into any troubles with, then try again.
The "Win7 downgraded from Win8" bit makes me nervous too, but I can't toss any experientialia at you about it.
I guess you already asked if they have Kaspersky?
Do they have any other ppa / ppam add ins (maybe hidden one from HKLM

No Add-In Tab Though Add-In is Loaded and Working

I wrote an Excel VBA add-in over ten years ago, which uses the old Commandbars to put a menu in Excel's Tools menu (in Excel 2003 and earlier) or in Excel's Add-Ins tab (in Excel 2007 and later). I've never had a problem with the menu appearing, in all versions of Excel from 97 through 2013.
But now a user says Excel Add-Ins menu not appearing for him in Excel 2013. Normally that means the add-in isn't loaded, but in his case the add-in is loaded and working. We know the add-in is loaded and working because the add-in adds user-defined worksheet functions, and those UDFs are working fine for him. But he wants to get to the add-in's menu and can't.
My googling showed that some people are having trouble with the Add-Ins menu in 2013, but I didn't find anything specific to this problem.
Yes, he's tried enabling the Add-Ins tab in Excel Options > Customize the Ribbon.
BTW this is an .xla add-in, not a COM add-in.
Any suggestions?
I have Excel 2010 and had the add-in tab disappear for MrExcel HTML add-in. I tried all types of suggestions - and finally found one that worked for me!
Go to the add-ins folder where you have your add in saved. Right click on the file, and select Properties. At the bottom of the General tab - if it says "Security" - check on the "Unblock" option.
Voila! My add-ins never disappear anymore!
Solved:
Solved this now but really weird solution if you enabled the Add-in whilst the Analysis ToolPaks were enabled it'd have the issue you above, but if you enabled the Add-in whilst the Analysis ToolPaks weren't ticked then went back in to it and re-ticked the Analysis ToolPaks it'd be fine and wouldn't disappear!
Was an extremely strange issue!
See Spiceworks
As far as I understood this is a problem with Excel 2013 (another attempt of the guys at Redmond to make our lives miserable with every update of their products). The workaround I've found is to include the following code into the ThisWorkbook module of the Addin:
Private Sub Workbook_Open()
Workbook_AddinUninstall
Workbook_AddinInstall
End Sub
Cheers!
I had similar issue with excel 2013. Add-in tab was missing. I went to Developer>>>Add-Ins and deselected the add-in I wanted. Click OK then repeat the process and select the same add-in. Click OK. The Add-In tab should appear.
See also https://www.excelcampus.com/vba/add-in-ribbon-disappears/
As of july 2016 the security settings in Excel disable the add-ins in the old default location. THe website shows how to set the directory to trusted status
I had a similar problem where two .xlam files that loaded and appeared in custom ribbon tabs in Excel 2010 didn't show up in the ribbon in Excel 2013 even though they were loading each time a workbook was opened. I tried all sorts of solutions - disabling the Analysis Toolpack, disabling and enabling the .xlam files, making sure the .xlam's attached XML file was up to date (I was thinking an MSO image I had in the XML code was no longer available in Excel 2013), but nothing worked. I eventually tried copying and renaming the .xlam file and enabled it in Excel and, strangely, it appeared in the ribbon.
I have no idea why it needed to be copied and renamed - it's almost like Excel 2013 needed a fresh copy of the .xlam file before it could show up. Very weird!
I've been looking for this answer for a LONG time and the previous code worked, but, for me, only with Workbook_Open() instead of Thisworkbook_Open()
Private Sub Workbook_Open()
Workbook_AddinUninstall
Workbook_AddinInstall
End Sub
Thanks for finding this!
I disabled the add-ins via the Developer tab, and then enabled them via File>Options>Add-Ins>Manage Add-Ins.
Voila!
You can Try by disabling macros with notification. (tried on 2016)
File->options->trust center->macro settings-> tick disable all macros with notification
It worked for me .
If I disabled and enabled, I could get the Add-Ins tab to appear, but every time I opened a document I had to repeat. This seemed to fix it for me:
File > Options > AddIns > Choose "XML Expansion Packs" > Go > Select "Microsoft Action Pane 3" > Attach > Ok
I have had similar problems with Excel 2016 (not with 2010 and 2017), and very strangely it was solved this way :
1) Desactivating the add-in
2) Quitting Excel
3) Activating the add-in
4) Going to File > Close (in French version : Fichier > Fermer)
And when I click "Close" the "Components" menu suddenly appear in Excel 2016 !
Good luck !
Had a similar problem in Excel 2010. Tried all the suggestions above, but to no avail. In the end it turned out that even though it was an .xll add-in, it somehow also was listed as a COM add-in. So going to File > Options > Add-In, then selecting Disabled Items from the list at the bottom of that window and enabling the add-in, worked for me. Now in the list of Active Application Add-ins it shows both the original Excel Add-in, and the unexpected COM add-in without location. Oh, and the tab is back of course. Go figure.

PowerPoint VBA - Preserving Custom CommandBar Settings on Close

I have developed a PowerPoint add-in for versions 2003 and earlier that generates a custom commandbar/toolbar on install.
I have no difficulty removing this commandbar on uninstall, but because it uses the Auto_Close event to do so, it also deletes the toolbar every time PowerPoint closes, preventing the user from permanently customizing the commandbar's position.
I've tried a conditional delete by checking if the add-in is registered or loaded, but Auto_Close seems to run before any unloading or deregistration.
Any ideas on how to delete the commandbar ONLY when the add-in is being uninstalled?
Sub Auto_Close()
Dim pptAddin As AddIn
For Each pptAddin In AddIns
If pptAddin.Name = "AddInName" And _
pptAddin.Registered <> msoTrue Then
Application.CommandBars("CommandBarName").Delete
End If
Next
End Sub
It's a good idea to do what you're doing - deleting your CommandBar when PowerPoint closes. That way if there is ever an error, your add-in doesn't leave artifacts in the UI that don't work.
For managing state though, many folks use GetSetting and SaveSetting for reading/writing to a sandboxed area in the Registry for VB/VBA programs. Look up the following functions on this page: GetSetting, SaveSetting, GetAllSettings, DeleteSetting. You can use these to manage your add-in's CommandBar between PowerPoint instances. It's relatively simple to use - here's a tutorial for Excel that would apply equally to PowerPoint.