2

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

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for reading through to my actual requirement and, of course, for the help. Much, much appreciated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.