none
Matching formatting of styles copied into document to Normal style RRS feed

  • Question

  • I have some document assembly macros which bring in autotext entries into differently formatted documents.  All the style names are the same in each document; however, the various documents may have different defaults.  For example, "Body Text First Indent" in one document may be single spaced and 12 point.  In another document, the same style may be Exactly 12 point and 14 point.  In both of these documents, Normal style reflects the defaults for the document. 

    When the autotext entries are dumped into the "new" document, I want the styles to behave based on Normal (or like the same named styles in the document), rather than coming in directly formatted from the autotext entries.

    Is there a way to easily make sure that all text coming is matches Normal as far as spacing and font size? 

    In addition, a few new styles may be introduced into the document via autotext.  I would like those new styles to also take on the spacing and font size to reflect those in Normal style.

    Thank you.


    • Edited by orlandp Wednesday, April 16, 2014 7:06 PM change title
    Wednesday, April 16, 2014 7:05 PM

Answers

  • Hi,

    >>Is there a way to easily make sure that all text coming is matches Normal as far as spacing and font size?  <<
    As far as I know, the AutoText keeps its format when it is inserted into the document. If you want to keep the format of AutoText as Normal template, I suggest you modifying the format of AutoText to the format you wanted.

    You can get more details about AutoText from links below:
    Automatically insert text
    AutoTextEntries Object

    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, April 17, 2014 11:25 AM
    Moderator
  • The definitions of the novel styles in the AutoText entries cannot altered by simple insertion as an AutoText. If you inserted the AT, copied it, and then pasted as plain text that would probably would help.

    The inserted text using a Style already in use in the receiving document should take on the Style attributes of the receiving document. If a style is based upon another style that is different in the receiving document, it should take on the underlying attributes of the based-on style in the receiving document. I am talking about what I expect rather than upon recent experience. If you are experiencing something different, please specify.

    See the IncludeText tutorial on my downloads page for examples of importing text where the styles of the original document and receiving document are different. This was not AutoText but the principles should be the same. While this is an old tutorial, I know of nothing that would work differently in recent versions of Word. Tutorials

    I imagine that it is possible to write a macro that will adjust AT entries to the receiving document. I would prefer to just set up the AT so that it works because most of the AutoText in my documents is placed there by AutoText fields rather than inserted via macro or manually.

    The following is my mishmash about AutoText, Building Blocks, and AutoCorrect. I don't think it will tell you how to do what you want, but it may contain links that will help. Automated Boilerplate Using Microsoft Word

    Like Fei, I recommend setting up your AutoText entries to act the way you want rather than trying to adapt them to a receiving document. This may be a bit of work (perhaps a lot of work) but I believe it to be your best bet. You may want to store alternative sets of your AutoText in some separate global templates that you load and unload programmatically. I do this for content, but it could be done for Styles as well.

    BTW, I seldom format anything in one of my templates using the normal style nor any style based on the normal style because of the loss of control I perceive over that style. Cindy Meister who also responded knows much more about this (and most Word subjects) than do I. If she says something that contradicts my musings, follow her directions.


    Charles Kenyon Madison, WI

    Thursday, April 17, 2014 8:03 PM

All replies

  • Hi,

    >>Is there a way to easily make sure that all text coming is matches Normal as far as spacing and font size?  <<
    As far as I know, the AutoText keeps its format when it is inserted into the document. If you want to keep the format of AutoText as Normal template, I suggest you modifying the format of AutoText to the format you wanted.

    You can get more details about AutoText from links below:
    Automatically insert text
    AutoTextEntries Object

    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, April 17, 2014 11:25 AM
    Moderator
  • Hi orlandp

    The BuildingBlock.Insert (or AutoText.Insert) method has two parameters, the second of which is optional and lets you specify whether the entry is inserted with or without its formatting. Set this to false and see if that helps.


    Cindy Meister, VSTO/Word MVP, my blog

    Thursday, April 17, 2014 5:41 PM
    Moderator
  • The definitions of the novel styles in the AutoText entries cannot altered by simple insertion as an AutoText. If you inserted the AT, copied it, and then pasted as plain text that would probably would help.

    The inserted text using a Style already in use in the receiving document should take on the Style attributes of the receiving document. If a style is based upon another style that is different in the receiving document, it should take on the underlying attributes of the based-on style in the receiving document. I am talking about what I expect rather than upon recent experience. If you are experiencing something different, please specify.

    See the IncludeText tutorial on my downloads page for examples of importing text where the styles of the original document and receiving document are different. This was not AutoText but the principles should be the same. While this is an old tutorial, I know of nothing that would work differently in recent versions of Word. Tutorials

    I imagine that it is possible to write a macro that will adjust AT entries to the receiving document. I would prefer to just set up the AT so that it works because most of the AutoText in my documents is placed there by AutoText fields rather than inserted via macro or manually.

    The following is my mishmash about AutoText, Building Blocks, and AutoCorrect. I don't think it will tell you how to do what you want, but it may contain links that will help. Automated Boilerplate Using Microsoft Word

    Like Fei, I recommend setting up your AutoText entries to act the way you want rather than trying to adapt them to a receiving document. This may be a bit of work (perhaps a lot of work) but I believe it to be your best bet. You may want to store alternative sets of your AutoText in some separate global templates that you load and unload programmatically. I do this for content, but it could be done for Styles as well.

    BTW, I seldom format anything in one of my templates using the normal style nor any style based on the normal style because of the loss of control I perceive over that style. Cindy Meister who also responded knows much more about this (and most Word subjects) than do I. If she says something that contradicts my musings, follow her directions.


    Charles Kenyon Madison, WI

    Thursday, April 17, 2014 8:03 PM