lwildernorva
06-15-2006, 08:24 AM
I have a question rather than a problem (I hope!). I use a combination of Word 2003 and Dragon NaturallySpeaking Legal. I have created a number of voice commands in Dragon that fire Word macros.
I have designed a Word macro that allows me to remove language that is in a new document, based on a template, if the language is not necessary in a particular case. In this template, two paragraphs in the document refer to an award of an attorney's fee. Those paragraphs are unnecessary if the person is unrepresented. At some point, it occurred to me that Word's Find and Replace functions can search for styles as well as particular words so I decided to create and apply a special style for these two paragraphs, called "Fee Language," and then, by a Dragon voice command, call the macro to search for and delete the text in any paragraphs in the document based on those styles. FYI, "Fee Language" has no formatting attributes other than those in Word's "Normal" style.
I realize, by the way, that I could have effectively reached the same result by omitting these two paragraphs from the template, inserting a bookmark, and then calling a macro that would search for the bookmark and either insert AutoText or insert a named file that would include the two paragraphs if necessary. At least at this point, I'll chalk this up to the enjoyment of finding more than one correct solution to a problem.
For reference, here's the code:
Sub DeleteFee()
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles("Fee Language")
Selection.Find.Replacement.ClearFormatting
Selection.Find.Execute Replace:=wdReplaceAll
End Sub The code works well. All I do is voice a command in Dragon to call the Word macro, and the language disappears immediately. I've used this method to create one macro and one template. It seems to work so well, in fact, that I am tempted to broaden its use.
I know, however, that sometimes a practice that looks good in limited circumstances becomes a nightmare when applied in more general circumstances. For instance, when I started writing code, I stored all my macros in Normal. Both through my own problems and from reading the advice in this forum, I understand that one or two macros stored in Normal may not mean much--but put hundreds in and you're asking for trouble. So I now store my macros in a special template created for that purpose and keep Normal clean.
I want to make sure I'm not about to fall into a similar trap by this use of styles. I'm interested in opinions about creating a number of styles solely for the purpose I've described here. Assuming I am not including all of these styles in Normal but simply storing the styles in the other templates I've created and that the nature of the documents I've created does not require more than one or two additional styles per template, is my method an efficient way to write code, or am I playing with fool's gold?
As I said, a question, but I'm willing to be told about any problems that I'm creating for myself.
Thanks!
I have designed a Word macro that allows me to remove language that is in a new document, based on a template, if the language is not necessary in a particular case. In this template, two paragraphs in the document refer to an award of an attorney's fee. Those paragraphs are unnecessary if the person is unrepresented. At some point, it occurred to me that Word's Find and Replace functions can search for styles as well as particular words so I decided to create and apply a special style for these two paragraphs, called "Fee Language," and then, by a Dragon voice command, call the macro to search for and delete the text in any paragraphs in the document based on those styles. FYI, "Fee Language" has no formatting attributes other than those in Word's "Normal" style.
I realize, by the way, that I could have effectively reached the same result by omitting these two paragraphs from the template, inserting a bookmark, and then calling a macro that would search for the bookmark and either insert AutoText or insert a named file that would include the two paragraphs if necessary. At least at this point, I'll chalk this up to the enjoyment of finding more than one correct solution to a problem.
For reference, here's the code:
Sub DeleteFee()
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles("Fee Language")
Selection.Find.Replacement.ClearFormatting
Selection.Find.Execute Replace:=wdReplaceAll
End Sub The code works well. All I do is voice a command in Dragon to call the Word macro, and the language disappears immediately. I've used this method to create one macro and one template. It seems to work so well, in fact, that I am tempted to broaden its use.
I know, however, that sometimes a practice that looks good in limited circumstances becomes a nightmare when applied in more general circumstances. For instance, when I started writing code, I stored all my macros in Normal. Both through my own problems and from reading the advice in this forum, I understand that one or two macros stored in Normal may not mean much--but put hundreds in and you're asking for trouble. So I now store my macros in a special template created for that purpose and keep Normal clean.
I want to make sure I'm not about to fall into a similar trap by this use of styles. I'm interested in opinions about creating a number of styles solely for the purpose I've described here. Assuming I am not including all of these styles in Normal but simply storing the styles in the other templates I've created and that the nature of the documents I've created does not require more than one or two additional styles per template, is my method an efficient way to write code, or am I playing with fool's gold?
As I said, a question, but I'm willing to be told about any problems that I'm creating for myself.
Thanks!