Consulting

Results 1 to 11 of 11

Thread: Include theme colors in an add-in

  1. #1
    VBAX Regular
    Joined
    Feb 2014
    Posts
    53
    Location

    Include theme colors in an add-in

    Is there a way to include custom theme colors in an add-in?

    I want my macro to change the user's theme colors. When I try recording a macro and manually changing the theme colors, the code comes out just loading the ThemeColorScheme I just created (i.e. it can't really record my actions). So what I need is some way to place a custom ThemeColorScheme (xml file) on each user's hard drive through my add-in. Is such a thing possible?


    Thanks

  2. #2
    Theme colors are not part of an Excel file, but rather special xml files in a special folder in your Office installation:

    C:\Program Files (x86)\Microsoft Office\Document Themes 14

    There is a utility to create your own, but it isn't very simple to do:

    http://openxmlthemebuilder.codeplex.com/
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

  3. #3
    VBAX Regular
    Joined
    Feb 2014
    Posts
    53
    Location
    Thanks for the reply.

    I actually already have my own theme (THMX) file. What I want is for my add-in macro to apply this theme. My code would be:

    ActiveWorkbook.ApplyTheme ("C:\Program Files (x86)\Microsoft Office\Document Themes 14\Custom.thmx")
    I was hoping the THMX (or XML) file could somehow be included in the add-in (because users won't have it), but maybe this just is not possible.

  4. #4
    Well, you could paste the content of the thmx file in your addin file and use a bit of code to push it out to a textfile.
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

  5. #5
    VBAX Regular
    Joined
    Feb 2014
    Posts
    53
    Location
    Do I have this right?

    1. Edit the thmx file in notepad
    2. Copy the text into VBA
    3. Add code to write this text into a txt file
    4. Rename the txt file to thmx (in VBA?)

  6. #6
    I would just paste it into a sheet, read the sheet from VBA later on and write to thmx file.
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

  7. #7
    VBAX Regular
    Joined
    Feb 2014
    Posts
    53
    Location
    There is no sheet (this is an add-in). So wouldn't I have to have the thmx text inside the VBA code already?

  8. #8
    I assumed this is an Excel add-in, which can have as many sheets as you like. I always edit my tools as normal workbooks, when done I save-as to add-in filetype.
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

  9. #9
    VBAX Regular
    Joined
    Feb 2014
    Posts
    53
    Location
    Huh. I must be misunderstanding some fundamental behavior of add-ins. I created mine in the way you describe (wrote the macro in a module within a workbook, then saved as xlam).
    Now that I have it installed I can call it anytime by pressing the associated button I added to the ribbon. But I can't see any sheets associated with it. Are they just hidden or....?

  10. #10
    You can toggle the visibility of an add-in by turning the IsAddin property of the Thisworkbook module to true/false. Do set it back to false before saving again.
    So basically yes, an addin is "just" a hidden workbook.
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

  11. #11
    VBAX Regular
    Joined
    Feb 2014
    Posts
    53
    Location
    Cool. That is very helpful.

    Thank you for all the assistance.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •