none
Styles and a template RRS feed

  • Question

  • We have a template and have added a routine so that users, when a  document based on the template is open, can make simple changes to styles without having to use the Word dialogue for style modification.

    When you use the Word dialogue for modifying a style there is a button "New documents based on this template".

    Is there some VBA code that is equivalent to clicking on this button, so that  the changes made in the document are also made to the template.

    Friday, April 12, 2013 11:35 AM

Answers

  • No, there's no VBA equivalent. Your code would need to open the template (as a document), make the changes in the styles there, as well, save and close it again. (Which is basically what Word is doing for the user in the background - and it only does it when the document is closing, not while the document is still open.)


    Cindy Meister, VSTO/Word MVP, my blog

    Friday, April 12, 2013 1:16 PM
    Moderator
  • Since asking the question above, I have got round the problem and includethe solution here in case someone else has the same problem.

    I got round the problem like this

        With Dialogs(wdDialogStyleManagement)
           SendKeys "{TAB 10}{LEFT}{ENTER}"
           .Show
        End With

      For Each atemp In Templates
         If LCase(atemp.Name) = "mytemplate.dotm" Then atemp.Save
      Next atemp

    Its a bit crude and depends on MS not changing the TAB order in the wdDialogStyleManagement dialog but it seems to work

    Monday, April 15, 2013 11:18 AM

All replies

  • Please disrregard the links in the above message. They are being added by something which is beyond our control.
    Friday, April 12, 2013 11:37 AM
  • No, there's no VBA equivalent. Your code would need to open the template (as a document), make the changes in the styles there, as well, save and close it again. (Which is basically what Word is doing for the user in the background - and it only does it when the document is closing, not while the document is still open.)


    Cindy Meister, VSTO/Word MVP, my blog

    Friday, April 12, 2013 1:16 PM
    Moderator
  • Since asking the question above, I have got round the problem and includethe solution here in case someone else has the same problem.

    I got round the problem like this

        With Dialogs(wdDialogStyleManagement)
           SendKeys "{TAB 10}{LEFT}{ENTER}"
           .Show
        End With

      For Each atemp In Templates
         If LCase(atemp.Name) = "mytemplate.dotm" Then atemp.Save
      Next atemp

    Its a bit crude and depends on MS not changing the TAB order in the wdDialogStyleManagement dialog but it seems to work

    Monday, April 15, 2013 11:18 AM