Recover code modules from corrupt vba pptm file - vba

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.

Related

Edit a .ppam PowerPoint add-in and save changes

I have a very useful PowerPoint add-in in a .ppam format. I used the following method (Edit a .ppam file for customizing an add-in) to open it in VBA and slightly modify to better suit my needs. I would like to save the changes now, so that they are in effect whenever I open PowerPoint with that add-in. However, when I click 'File -> Save' in VBA Editor and restart PowerPoint, the changes I made are no longer there.
How do I save them?
You can't. You can either copy/paste from the edited modules/forms/classes into new modules/forms/classes in a PPTM file or export each of the modules/forms/classes and then import them into a PPTM.
I am maintaining one PowerPoint Add-in myself for a long time.
My way of doing it:
keeping the master file in ".pptm", and always maintain it there
as soon as the master files opens (can be hooked in Ribbonloaded event), it'll disable the running add-in
I developed a button to release current .pptm file replacing the .ppam add-in, so as long as I want to publish again, I'll click it.

Creating PowerPoint Add-Ins from VBA defined Macros

So I've created a Macro in a PowerPoint Presentation and I would like to make this Macro readily available to someone else. From what I have gathered, the best way to do this is to create an Add-in.
I have come across several articles stating to do the following, but I am still running into problems:
Open a new PowerPoint Presentation
Create a macro using VBA
Exit VBA, and save the Presentation as a .ppam
Under the Developer Tab, click on the "PowerPoint Add-ins" button
Click the "Add New..." option, and browse for your recently created
.ppam file
Click Load
Click Close
Click Add-ins
You should now see your new Add-in
I have done everything mentioned above and can even see the new Add-in when I select PowerPoint Add-Ins. I'm here because I can't find a way to run the new Add-in, and I don't want it to automatically load on startup or to interfere with the presentation by creating a button on the slides. As instead, I would like to allow the user to run this Add-in from the Ribbon.
Thoughts?
First, save as PPTM. THEN save as PPAM. If you only save as PPAM, you won't be able to go back and edit your code later to correct problems.
To launch your add-in from the ribbon, you must include RibbonX code (a type of XML) to your PPAM or PPTM (best to add it to the PPTM ... it'll become part of the PPAM automatically then).
There's an excellent book on RibbonX that'll save you hours of time:
http://www.amazon.com/RibbonX-Customizing-Office-2007-Ribbon/dp/0470191112
This is a good starting point if you don't want to buy the book:
https://blogs.msdn.microsoft.com/jensenh/tag/all-office-2007-ui-posts/
While you can manually unzip PPTM/PPTX/PPAM files and add the RibbonX code using any text editor, it's silly to do so. Instead use this free tool:
http://openxmldeveloper.org/blog/b/openxmldeveloper/archive/2009/08/07/7293.aspx

Excel VBA Add-in reference not listed

I saved an Excel project as type "Excel Add-in" to the default directory under AppData/Roaming/Microsoft/AddIns. The extension is .xlam. Upon reopening Excel, this Add-in was listed under File-->Options-->Add-ins and I toggled the checkbox to select it.
In the VBA editor, this Add-in is displayed along with the other Add-ins listed under File-->Options-->Add-ins but none of the code can be called. It is not listed in the available references and, when I use this window to browse for it, it is not detected in the AddIns directory -- despite clearly being there.
I notice that all of the other Add-in projects that were installed without problem are .xla file extensions. We are using Excel 2010 but the problem is identical when I save the project as type "Excel 97-2003 Add-in" with an extension of .xla.
Advice is appreciated.
In the VBA Editor click on ThisWorkbook for your Add-In. In the Properties Window, make sure that IsAddin is set to True. This also makes it easier to edit your addin. When you need to make changes to the add-in code, follow these steps:
Set the property to False
Make your edits
Change the property back to True
Click on the Save icon
Close Excel.
You will be prompted if you want to save the changes made to
"addin.xlam", click yes.
And as #nwhaught suggested, make sure your functions are set to Public and not Private.

Listview on worksheet generates cannot insert object error Excel 2010

Hi I have an Excel 2003 application which has a listview embedded in the worksheet. It no longer works on Excel 2010.
I re-registered the ocx using regsvr32 C:\Windows\System32\MSCOMCTL.OCX as per advice.
This works for listviews on forms, but not for the worksheet.
Microsoft advises that Cannot insert object can be generated if the control is form specific and an attempt is made to add to the worksheet.
Can the listview be used in Excel 2010 on a worksheet
If so how?
Otherwise a rewrite will be required.
That happened to my Excel files using ActiveX or any sort of automation. The solution was confused at the beginning but the following link will help you.
Create a batch to remove cached control type libraries (extender files *.EXD) files from Windows
Opening each of the projects (Excel with macros)
Switch the file to design mode
Open VBA Code (Alt-F11) to edit any module and press from the main menu > Debug > Compile VBAProject
Switch back to Run Mode
Save and Close File
Reopen the file & test
Form Controls stop working after December 2014 Updates

XLAM / XLA Addins: is there a better way?

This post is about installing XLAM's without creating links. (Everyone hates links). Consider the trivial addin:
Public Function UDF_HELLO(x)
UDF_HELLO = "Hello " & x
End Function
Put this code and nothing else into a Module and save as "Hello.xlam" on the Desktop (and NOT in the default excel addins folder). Next, while HELLO.XLAM is still open, create a new XLSX workbook with the formula
=UDF_Hello("world")
in cell A1, which simply displays "Hello world" in that cell. Save the workbook and exit Excel. Now, if you reopen the workbook without the XLAM, Excel will complain about "links to other sources ...". Whether you click "Update" or "Don't Update", Excel will mangle the formula in cell A1 like this:
='C:\Documents and Settings\tpascale\Desktop\Hello.xlam'!UDF_Hello("world")
Very often this "forced-linkage" is NOT desirable. In my computing environment there is a lot of ad-hoc analysis and it makes no sense to impose an install regimen on every XLAM we throw together to solve the problem of the day. I just want to hand out XLAM files to users and let those users open them when they need them, WITHOUT having to worry about the slightest mis-step causing their formulas to get mangled.
QUESTION:
Is there a way to instruct Excel to NEVER construct external links for UDFs, and simply to use UDFs if they're loaded and return #VALUEs otherwise ?
I don't know of a way around this with .xla/.xlam add-ins.
But this issue does not occur with .xll add-ins.
These can be created in C using the Excel 2010 SDK, or in managed languages like VB.NET or C# using the free Excel-DNA library.
(Disclaimer: I'm the developer of Excel-DNA. This issue is one of the reasons I went with the .xll interface for making managed UDF add-ins.)
You can have them open the .xla file and have an Auto_Open procedure install the add-in.
http://www.vbaexpress.com/kb/getarticle.php?kb_id=693
After excel closes you can have the add-in uninstall itself.
oAddIn.Installed = False
You can give your add-in a setting for the user to not uninstall after every use by using a worksheet named something then have cell A1 equal to true or false.
I haven't tested this but hopefully it works for you.
This should work to resolve your issue though it does not instruct Excel regarding external links. I have tested it myself by creating the XLAM, saving it to my desktop, installing it in the Excel add-ins and then using it on a new workbook.
Steps:
Once you have saved the add-in, close it.
Go to Excel Options-->Add-Ins
In the Manage drop-down select Excel Add-ins and press 'Go'
In the 'Add-Ins'dialogue that appears click 'Browse' and navigate to
the add-in you just created. Select it and hit 'Ok'
If prompted to save the add-in in the add-ins folder, select 'No'.
Selecting 'Yes' may cause an error if the add-in file suffix does
not match the version of Excel being used.
Your add-in should appear in the 'Add-Ins available' scrollbox,
check its box and hit 'Ok'
Your add-in should now be active whenever you open Excel.
Test this by opening a new workbook and try using your UDF.
Best,
I usually solve this problem by:
Saving an XLA/XLAM file (outside Personal folder, of course)
Connect to it in Tools - Addins
Write pseudo macros in your current Excel file that links to those macros / functions in the XLA/XLAM file.
See the detailed instructions in my reply here.