Home |
Search |
Today's Posts |
#1
|
|||
|
|||
Multiple Styles - Filtering/Replacing
We have a document template we are developing that has two sets of styles,
one for numbered headers/section and one for unnumbered. Is there anyway that we can control which styles are shown to the user based on say a userform selection where the user picks if they want the numbered or unnumbered version? Secondly, is there anyway to replace all the styles throughout a document from one type to another, so that a macro could possibly be used to change all the styles from the numbered version to the unnumbered version? |
#2
|
|||
|
|||
Answered in the vba.general group. Please do not post multiple copies of the
same question to different groups -- Regards Jonathan West - Word MVP www.intelligentdocuments.co.uk Please reply to the newsgroup "ML" wrote in message ... We have a document template we are developing that has two sets of styles, one for numbered headers/section and one for unnumbered. Is there anyway that we can control which styles are shown to the user based on say a userform selection where the user picks if they want the numbered or unnumbered version? Secondly, is there anyway to replace all the styles throughout a document from one type to another, so that a macro could possibly be used to change all the styles from the numbered version to the unnumbered version? |
#3
|
|||
|
|||
If you are going to write macros anyway, and need the ability to swap
between numbered and unnumbered formats rather than mix and match, then probably the neatest way of doing this is to use a single set of styles, and macros to number/unnumber them. Unnumbering is fairly straightforward - statements like: ActiveDocument.Styles("Heading 1").LinkToListTemplate _ ListTemplate:=Nothing for each of the styles. Numbering is a bit trickier, as you need to do this in a way that doesn't build up list templates. Have a look at the code at http://www.syntagma.demon.co.uk/FAQs...le.htm#example for the basic model. Ignore the first bit which sets up a specific style - the main statements you want start at the comment "Create the list template if it doesn't exist. " You'll need to adapt the code for your styles and numbering format, and provide a name for your list template. (If you record a macro of setting up headings from the top level style, following the manual steps as described in http://www.shaunakelly.com/word/numb...Numbering.html you'll see what parameters you need.) -- Margaret Aldis - Microsoft Word MVP Syntagma partnership site: http://www.syntagma.co.uk Word MVP FAQ site: http://www.word.mvps.org "ML" wrote in message ... We have a document template we are developing that has two sets of styles, one for numbered headers/section and one for unnumbered. Is there anyway that we can control which styles are shown to the user based on say a userform selection where the user picks if they want the numbered or unnumbered version? Secondly, is there anyway to replace all the styles throughout a document from one type to another, so that a macro could possibly be used to change all the styles from the numbered version to the unnumbered version? |
#4
|
|||
|
|||
Thanks! This might do exatly what I need.
Basically I want to have the userform allow the user to select the desired numbering or nonnumbering style and add or remove the numbers based on this. So would calling the following on each style basically remove the numbering and leave the rest of the style formatting as is? Not 100% sure what you mean on this in terms of unnumbering. ActiveDocument.Styles("Heading 1").LinkToListTemplate _ ListTemplate:=Nothing "Margaret Aldis" wrote in message ... If you are going to write macros anyway, and need the ability to swap between numbered and unnumbered formats rather than mix and match, then probably the neatest way of doing this is to use a single set of styles, and macros to number/unnumber them. Unnumbering is fairly straightforward - statements like: ActiveDocument.Styles("Heading 1").LinkToListTemplate _ ListTemplate:=Nothing for each of the styles. Numbering is a bit trickier, as you need to do this in a way that doesn't build up list templates. Have a look at the code at http://www.syntagma.demon.co.uk/FAQs...le.htm#example for the basic model. Ignore the first bit which sets up a specific style - the main statements you want start at the comment "Create the list template if it doesn't exist. " You'll need to adapt the code for your styles and numbering format, and provide a name for your list template. (If you record a macro of setting up headings from the top level style, following the manual steps as described in http://www.shaunakelly.com/word/numb...Numbering.html you'll see what parameters you need.) -- Margaret Aldis - Microsoft Word MVP Syntagma partnership site: http://www.syntagma.co.uk Word MVP FAQ site: http://www.word.mvps.org "ML" wrote in message ... We have a document template we are developing that has two sets of styles, one for numbered headers/section and one for unnumbered. Is there anyway that we can control which styles are shown to the user based on say a userform selection where the user picks if they want the numbered or unnumbered version? Secondly, is there anyway to replace all the styles throughout a document from one type to another, so that a macro could possibly be used to change all the styles from the numbered version to the unnumbered version? |
#5
|
|||
|
|||
Yes, by 'unnumber' I mean remove the numbering, leaving everything else as
is. of course, you might want to fiddle with the indents or something else as well, depending on your format (use of margins etc.) for the two different styles, but you'll see that in your actual document. -- Margaret Aldis - Microsoft Word MVP Syntagma partnership site: http://www.syntagma.co.uk Word MVP FAQ site: http://www.word.mvps.org "ML" wrote in message ... Thanks! This might do exatly what I need. Basically I want to have the userform allow the user to select the desired numbering or nonnumbering style and add or remove the numbers based on this. So would calling the following on each style basically remove the numbering and leave the rest of the style formatting as is? Not 100% sure what you mean on this in terms of unnumbering. ActiveDocument.Styles("Heading 1").LinkToListTemplate _ ListTemplate:=Nothing "Margaret Aldis" wrote in message ... If you are going to write macros anyway, and need the ability to swap between numbered and unnumbered formats rather than mix and match, then probably the neatest way of doing this is to use a single set of styles, and macros to number/unnumber them. Unnumbering is fairly straightforward - statements like: ActiveDocument.Styles("Heading 1").LinkToListTemplate _ ListTemplate:=Nothing for each of the styles. Numbering is a bit trickier, as you need to do this in a way that doesn't build up list templates. Have a look at the code at http://www.syntagma.demon.co.uk/FAQs...le.htm#example for the basic model. Ignore the first bit which sets up a specific style - the main statements you want start at the comment "Create the list template if it doesn't exist. " You'll need to adapt the code for your styles and numbering format, and provide a name for your list template. (If you record a macro of setting up headings from the top level style, following the manual steps as described in http://www.shaunakelly.com/word/numb...Numbering.html you'll see what parameters you need.) -- Margaret Aldis - Microsoft Word MVP Syntagma partnership site: http://www.syntagma.co.uk Word MVP FAQ site: http://www.word.mvps.org "ML" wrote in message ... We have a document template we are developing that has two sets of styles, one for numbered headers/section and one for unnumbered. Is there anyway that we can control which styles are shown to the user based on say a userform selection where the user picks if they want the numbered or unnumbered version? Secondly, is there anyway to replace all the styles throughout a document from one type to another, so that a macro could possibly be used to change all the styles from the numbered version to the unnumbered version? |
#6
|
|||
|
|||
Worth also noting that unless you've some other user input to collect you
can avoid the user form and just give the user menu items or toolbar buttons for 'number headings' or 'unnumber headings' - or even a single toggle button to check whether the styles are currently numbered (look at the linked list template) and run one or other of the macros as appropriate. I'd also recommend resetting the heading paragraphs to style after change of numbering format - keeps everything clean and can be used to tidy up when user or Word has applied numbering as direct formatting (where changing styles won't help). Code something like: Dim apara As Paragraph Dim stylename As String For Each apara In ActiveDocument.Paragraphs stylename = apara.Style If stylename Like "Heading*" Then apara.Reset Next apara -- Margaret Aldis - Microsoft Word MVP Syntagma partnership site: http://www.syntagma.co.uk Word MVP FAQ site: http://www.word.mvps.org "Margaret Aldis" wrote in message ... Yes, by 'unnumber' I mean remove the numbering, leaving everything else as is. of course, you might want to fiddle with the indents or something else as well, depending on your format (use of margins etc.) for the two different styles, but you'll see that in your actual document. -- Margaret Aldis - Microsoft Word MVP Syntagma partnership site: http://www.syntagma.co.uk Word MVP FAQ site: http://www.word.mvps.org "ML" wrote in message ... Thanks! This might do exatly what I need. Basically I want to have the userform allow the user to select the desired numbering or nonnumbering style and add or remove the numbers based on this. So would calling the following on each style basically remove the numbering and leave the rest of the style formatting as is? Not 100% sure what you mean on this in terms of unnumbering. ActiveDocument.Styles("Heading 1").LinkToListTemplate _ ListTemplate:=Nothing "Margaret Aldis" wrote in message ... If you are going to write macros anyway, and need the ability to swap between numbered and unnumbered formats rather than mix and match, then probably the neatest way of doing this is to use a single set of styles, and macros to number/unnumber them. Unnumbering is fairly straightforward - statements like: ActiveDocument.Styles("Heading 1").LinkToListTemplate _ ListTemplate:=Nothing for each of the styles. Numbering is a bit trickier, as you need to do this in a way that doesn't build up list templates. Have a look at the code at http://www.syntagma.demon.co.uk/FAQs...le.htm#example for the basic model. Ignore the first bit which sets up a specific style - the main statements you want start at the comment "Create the list template if it doesn't exist. " You'll need to adapt the code for your styles and numbering format, and provide a name for your list template. (If you record a macro of setting up headings from the top level style, following the manual steps as described in http://www.shaunakelly.com/word/numb...Numbering.html you'll see what parameters you need.) -- Margaret Aldis - Microsoft Word MVP Syntagma partnership site: http://www.syntagma.co.uk Word MVP FAQ site: http://www.word.mvps.org "ML" wrote in message ... We have a document template we are developing that has two sets of styles, one for numbered headers/section and one for unnumbered. Is there anyway that we can control which styles are shown to the user based on say a userform selection where the user picks if they want the numbered or unnumbered version? Secondly, is there anyway to replace all the styles throughout a document from one type to another, so that a macro could possibly be used to change all the styles from the numbered version to the unnumbered version? |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Importing sub documents with AddFromFile is creating multiple styles | Microsoft Word Help | |||
Styles in Word 2003 | Microsoft Word Help | |||
Importing sub documents with AddFromFile is creating multiple styles | Formatting Long Documents | |||
removing styles across multiple documents | Microsoft Word Help | |||
Multiple styles in a single paragraph | Microsoft Word Help |