If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Underlining in form fields
OK, I have a template that I created which is more or
less a giant table with a form field or drop-down menu in each cell. One of my coworkers is using this form, and wants to underline text within the form field. Not the whole field, just a portion of the text. After talking to him, it looks like almost everythign that he wants to underline appears in a common form: XX- #, where X is a capital letter and # is a number. Is there any way, perhaps through a macro, for me to allow him to do this, or to just have Word automatically underline all instances of this sort of text? Thanks, Les |
#2
|
|||
|
|||
Underlining in form fields
Les,
The following macro set to run on exit from each field might work: Sub UnderlineInField() ' ' Macro recorded June 9, 2004 by CDR Gregory K. Maxey ActiveDocument.Unprotect Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting Selection.Find.Replacement.Font.Underline = wdUnderlineSingle With Selection.Find .Text = "([A-Z]{2})-([0-9])" .Replacement.Text = "\1-\2" .Forward = True .Wrap = wdFindContinue .Format = True .MatchCase = False .MatchWholeWord = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True End Sub -----Original Message----- OK, I have a template that I created which is more or less a giant table with a form field or drop-down menu in each cell. One of my coworkers is using this form, and wants to underline text within the form field. Not the whole field, just a portion of the text. After talking to him, it looks like almost everythign that he wants to underline appears in a common form: XX- #, where X is a capital letter and # is a number. Is there any way, perhaps through a macro, for me to allow him to do this, or to just have Word automatically underline all instances of this sort of text? Thanks, Les . |
#3
|
|||
|
|||
Underlining in form fields
I tried pasting that into my document, and it's giving me
an error on the fourth line, and the last two lines. It says "syntax error" when I try to compile. I'm afraid I'm not a programmer, so I don't really know how to fix that. Thanks for you help, though! Let me know what to do to fix it so I can try it to see if it works! Les -----Original Message----- Les, The following macro set to run on exit from each field might work: Sub UnderlineInField() ' ' Macro recorded June 9, 2004 by CDR Gregory K. Maxey ActiveDocument.Unprotect Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting Selection.Find.Replacement.Font.Underline = wdUnderlineSingle With Selection.Find .Text = "([A-Z]{2})-([0-9])" .Replacement.Text = "\1-\2" .Forward = True .Wrap = wdFindContinue .Format = True .MatchCase = False .MatchWholeWord = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True End Sub -----Original Message----- OK, I have a template that I created which is more or less a giant table with a form field or drop-down menu in each cell. One of my coworkers is using this form, and wants to underline text within the form field. Not the whole field, just a portion of the text. After talking to him, it looks like almost everythign that he wants to underline appears in a common form: XX- #, where X is a capital letter and # is a number. Is there any way, perhaps through a macro, for me to allow him to do this, or to just have Word automatically underline all instances of this sort of text? Thanks, Les . . |
#4
|
|||
|
|||
Underlining in form fields
Would it be possible to have this macro run not on exit,
but as a shortcut key when the document is completed? Thanks, Les -----Original Message----- Les, The following macro set to run on exit from each field might work: Sub UnderlineInField() ' ' Macro recorded June 9, 2004 by CDR Gregory K. Maxey ActiveDocument.Unprotect Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting Selection.Find.Replacement.Font.Underline = wdUnderlineSingle With Selection.Find .Text = "([A-Z]{2})-([0-9])" .Replacement.Text = "\1-\2" .Forward = True .Wrap = wdFindContinue .Format = True .MatchCase = False .MatchWholeWord = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True End Sub -----Original Message----- OK, I have a template that I created which is more or less a giant table with a form field or drop-down menu in each cell. One of my coworkers is using this form, and wants to underline text within the form field. Not the whole field, just a portion of the text. After talking to him, it looks like almost everythign that he wants to underline appears in a common form: XX- #, where X is a capital letter and # is a number. Is there any way, perhaps through a macro, for me to allow him to do this, or to just have Word automatically underline all instances of this sort of text? Thanks, Les . . |
#5
|
|||
|
|||
Underlining in form fields
Hi Les,
OK, I have a template that I created which is more or less a giant table with a form field or drop-down menu in each cell. One of my coworkers is using this form, and wants to underline text within the form field. Not the whole field, just a portion of the text. After talking to him, it looks like almost everythign that he wants to underline appears in a common form: XX- #, where X is a capital letter and # is a number. Is there any way, perhaps through a macro, for me to allow him to do this, or to just have Word automatically underline all instances of this sort of text? In order to allow formatting in a protected form, macros are required. If the form fields were not in a table, then a fairly simple macro would work to unprotect, format the selection, reprotect. The problem you run into with a table is that the user can't select just "bits and pieces" in a form field. This makes a simple macro solution impossible. But, if you have a pattern, and that's all that's needed (IOW, the user isn't going to come and say now he wants to bold this and make that red, and...), you should be able to handle it OK. You'll find the "framework code" for unprotecting/reprotecting in the Forms section of my website. For what goes in between, you should be able to use the macro recorder to get the basics. 1. Try using Edit/Find to match this pattern (i.e. with wildcards) 2. Then practice Edit/Replace to pick this up and replace with the "Find What" text and apply underline formatting. 3. Once you have this working, record it in a macro 4. Then you have to decide whether to do a "Replace All" in the entire document, just the field where the current selection is, or just in particular fields. Cindy Meister INTER-Solutions, Switzerland http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003) http://www.word.mvps.org This reply is posted in the Newsgroup; please post any follow question or reply in the newsgroup and not by e-mail :-) |
#6
|
|||
|
|||
Underlining in form fields
Les,
The error is resulting form the blasted text wrapping that occurs in this newsgroup. The fifth line is text wrapped. Bring it up and make the fourth and fifth line all one line. Same with the last two. Bring the "NoReset: ..." up to the preceeding line. Leave the End Sub part on the final line. Yes you can run this macro after the document is completed. See: http://word.mvps.org/FAQs/Customizat...mdOrMacroToToo lbar.htm Again the text wrapping strikes, so be sure to paste the entire link above in your browser. -----Original Message----- I tried pasting that into my document, and it's giving me an error on the fourth line, and the last two lines. It says "syntax error" when I try to compile. I'm afraid I'm not a programmer, so I don't really know how to fix that. Thanks for you help, though! Let me know what to do to fix it so I can try it to see if it works! Les -----Original Message----- Les, The following macro set to run on exit from each field might work: Sub UnderlineInField() ' ' Macro recorded June 9, 2004 by CDR Gregory K. Maxey ActiveDocument.Unprotect Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting Selection.Find.Replacement.Font.Underline = wdUnderlineSingle With Selection.Find .Text = "([A-Z]{2})-([0-9])" .Replacement.Text = "\1-\2" .Forward = True .Wrap = wdFindContinue .Format = True .MatchCase = False .MatchWholeWord = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True End Sub -----Original Message----- OK, I have a template that I created which is more or less a giant table with a form field or drop-down menu in each cell. One of my coworkers is using this form, and wants to underline text within the form field. Not the whole field, just a portion of the text. After talking to him, it looks like almost everythign that he wants to underline appears in a common form: XX- #, where X is a capital letter and # is a number. Is there any way, perhaps through a macro, for me to allow him to do this, or to just have Word automatically underline all instances of this sort of text? Thanks, Les . . . |
Thread Tools | |
Display Modes | |
|
|