How to apply a color theme to a document RRS feed

  • Question

  • I have an EXCEL 2007 macro which I'm using to generate a WoRD 2007 document - I have everything working apart from applying the colour scheme.  I've tried to record the 'macro' for this in WORD, but get no code recorded.  After generating the document I'm manually selecting [from the HOME 'tab'] Change Styles / Colors / Custom / "Custom 1".

    In the absence of any code being generated by record macro, after hours of trolling through the meaningless help tect on themes, I've tried "ActiveDocument..ApplyTheme ("Custom 1")" with out success.

    Does anyone know how to do this please, where is it all documented and where are Custom Colour themes stored.  Platform is Win7.


    Sunday, July 17, 2011 7:50 PM

All replies

  • Here is a link to the developer reference on the ApplyTheme method.

    The important part is to look at the folder path they reference and find in there the available themes to choose from.

    Kind Regards, Rich ...
    Monday, July 18, 2011 2:04 AM
  • Rich,

    Thank you, I have seen this before but am none the wiser.  I might be doing completely the wrong thing to achieve what I want.

    Directly in WORD I can see my way to manually setting the colour scheme "Custom 1", however when trying to record a marco of the actions so that I can do this progammatically no code is recorded.  In the absence of any other knowledge, I have assumed that the .ApplyTheme method is what I need.

    ActiveDocument.ApplyTheme ("Custom 1") throws an error 'The specified theme cannot befound'.  Even if I use a name of a built-in theme, I get the same error message, yet in debug mode, if I type '?ActiveDocument.ActiveTheme' the name returned is that which was used in teh FAILED ApplyTheme method.  Any clues what's happening here?  Have I got the right approach tp what I'm trying to do?

    Note I can find all of the build in themes under Program files/Microsoft Office/... etc, though I guess Custom 1 will be in my user area, however under Win7 (which I somewhat new to) I do not seem to be able to access the local configuration data as one could under XP (...profiles/user/application data/local settings/... etc) thus I cannot locate the files for teh CUSTOM 1 theme.


    Monday, July 18, 2011 3:06 PM
  • >  I have assumed that the .ApplyTheme method is what I need.
    That is a false assumption :-(
    ApplyTheme applies an old-style Theme - which you probably never used.
    To apply Word 2007 Themes use ...
    Custom themes are stored in your User Templates location (by default C:\Users\(userid)\AppData\Roaming\Microsoft\Templates) in a folder called "Document Themes".
     ... BUT ...
    As far as I know, you can only apply a complete Theme, not a Color Scheme by itself.


    Monday, July 18, 2011 4:31 PM
  • Tony,

    Thank you most helpful, but not quite there yet!

    Following your guidance (locating personal settings under Win7) I found what I was looking for - well nearly... "C:\Users\Kevin\AppData\Roaming\Microsoft\Templates\Document Themes\Theme Colors\Custom 1.xml" seems to be a match (based on name and location) to what I need to apply, however (1) this ids not a .thmx file and I thus guess not suitable for the .ApplyDocumentTheme method and (2) tying to use it throws an error.

    Runtime error '-2147467259 (80004005)' Method 'ApplyDocumentTheme' of object '_Document' failed.

    I assume that this is due to the file not being a .thmx file?  Do you know of any other relevant method that the .xml file can be used to apply the 'colour' file with please?


    Tuesday, July 19, 2011 7:25 AM