Error 400 Caused By Custom Ribbon ?

  • Hi,


    I am currently working on a a project to obsfucate VBA code I use the following code from the late Chip Pearson's article on 'Programming The VBA Editor'.


    Chip Pearson - Programming The VBA Editor

    http://www.cpearson.com/excel/vbe.aspx


    to get the project modules which I then loop through to obsfucate the code by generating random names for the projects variables and procedures.

    The code is called by...

    Code
    1. GetModules objWorkbookToObsfucate

    This works fine, until I try obsfucating a project that has a custom ribbon. When I receive two 400 Errors :( when ThisWorkbook is accessed. If I remove the Custom Ribbon XML I don't get the errors. The ribbon code for the project all works perfectly. So failing to understand why I am getting the 400 Errors ?


    Probably a bit of a long shot but was wondering if anyone has experienced a similar problem ?


    Regards,


    Tom Rowe

  • Tom Rowe

    Changed the title of the thread from “Error 400 Caused By Custom Ribbon” to “Error 400 Caused By Custom Ribbon ?”.
  • Curious as to how the ribbon callbacks could work if you give all procedures random names?

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why

  • Hi Rory,


    Regarding : Curious as to how the ribbon callbacks could work if you give all procedures random names?


    By changing the callbacks manually in the Ribbon XML Files to the random names which I keep a log of. Or alternatively don't change them. But haven't got the project to the state yet where I can successfully compile and run the obsfucated code. :)


    Regards,


    Tom Rowe.

  • Sounds like a real PITA to me. ;)


    Anyway, at what point are you calling this code? If it's directly after opening the workbook in code, perhaps the Ribbon is still executing callbacks?

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why

  • Hi Rory,

    Yes I have discovered that VBA Code Obsfucation is not an exact science.:)


    In the project I was obfuscating I had an onLoad event. Which I don't actually do anything with but always include if I want to do so in the future.

    Code
    1. <customUI onLoad="ConwaysGameOfLifeRibbonOnLoad" xmlns="http://schemas.microsoft.com/office/2006/01/customui">
    2. <ribbon startFromScratch="false">
    3. <tabs>
    4. <tab id="conways_game_of_life" label="Conway's Game of Life">

    So I deleted it and you guessed it I no longer get the two 400 Errors. So most probably as you suggested the Ribbon was still executing the callback. The reason there were two was I have two instances of the project to obsfucate open. The initial a Read Only which I then do a SaveAs for the obsfucated version.


    On an even happier note the Conway's Game of Life project obsfucated successfully on my latest VBA Code Obsfucator version and all the code worked perfectly.


    Regards,


    Tom Rowe