Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Macro question
I have about 50 Word documents that I have to change 4 date fields to
SaveDate format. I wanted to record a macro to delete the date, create a text box, and install the SaveDate field. Not being too familiar with macros, can this be accomplished? I tried to record the macro but it won't let me delete text or create a new line. The doc is not protected. Am I missing something? The mouse cursor has the tape icon on it but I really cannot do any editing. Is this nomal? TY |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Macro question
Why the text box? Generally fields in text boxes are not a good idea, and it
makes the programming a lot more tricky. To get you started on handling a bunch of files, you might want to look at http://word.mvps.org/FAQs/MacrosVBA/BatchFR.htm which is on doing a replace on all files in a directory. In your case it would be relatively simple to adapt this to replace all DATE codes with SAVEDATE codes, which may not be what you want. -- Charles Kenyon Word New User FAQ & Web Directory: http://addbalance.com/word Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome! My criminal defense site: http://addbalance.com --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom. "TBoe" wrote in message news I have about 50 Word documents that I have to change 4 date fields to SaveDate format. I wanted to record a macro to delete the date, create a text box, and install the SaveDate field. Not being too familiar with macros, can this be accomplished? I tried to record the macro but it won't let me delete text or create a new line. The doc is not protected. Am I missing something? The mouse cursor has the tape icon on it but I really cannot do any editing. Is this nomal? TY |
#3
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Macro question
Thanks for the info Charles. The reason for the text box was for formating
issues. I guess I really don't need them. Next to the date is a sentence and I thought it would be easier if you had to enter a date then the test would not move. "Charles Kenyon" wrote: Why the text box? Generally fields in text boxes are not a good idea, and it makes the programming a lot more tricky. To get you started on handling a bunch of files, you might want to look at http://word.mvps.org/FAQs/MacrosVBA/BatchFR.htm which is on doing a replace on all files in a directory. In your case it would be relatively simple to adapt this to replace all DATE codes with SAVEDATE codes, which may not be what you want. -- Charles Kenyon Word New User FAQ & Web Directory: http://addbalance.com/word Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome! My criminal defense site: http://addbalance.com --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom. "TBoe" wrote in message news I have about 50 Word documents that I have to change 4 date fields to SaveDate format. I wanted to record a macro to delete the date, create a text box, and install the SaveDate field. Not being too familiar with macros, can this be accomplished? I tried to record the macro but it won't let me delete text or create a new line. The doc is not protected. Am I missing something? The mouse cursor has the tape icon on it but I really cannot do any editing. Is this nomal? TY |
#4
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Macro question
A table would do the same thing. The thing about text boxes is that they are
not in the same "layer" of the document as your regular text. It adds a big level of complexity. If you want something in a margin, you could put it in a frame (which acts a lot like a text box, but is still in the text layer). The following code creates a frame with a SaveDate field for the left margin. Sub Macro6() ' ' Macro6 Macro ' Macro recorded 4/13/2006 by Charles Kyle Kenyon ' With Selection .Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _ "SAVEDATE \@ ""d-MMM-yy"" ", PreserveFormatting:=False .MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend ActiveDocument.Frames.Add Range:=Selection.Range With .Frames(1) .Select .TextWrap = True .WidthRule = wdFrameExact .Width = InchesToPoints(0.8) .HeightRule = wdFrameAuto .HorizontalPosition = wdFrameLeft .RelativeHorizontalPosition = wdRelativeHorizontalPositionPage .VerticalPosition = InchesToPoints(0) .RelativeVerticalPosition = wdRelativeVerticalPositionParagraph .HorizontalDistanceFromText = InchesToPoints(0.1) .VerticalDistanceFromText = InchesToPoints(0) .LockAnchor = False End With .Collapse .ParagraphFormat.Alignment = wdAlignParagraphCenter .TypeText Text:="Saved" .TypeParagraph End With End Sub It is very sloppy, based on recording. Run it to get a frame. Adjust the formatting of the frame and the field until they are to your liking. Save this as an AutoText entry. Then, write your code to find date fields and in place of the date field insert the Autotext entry, which will be the framed SaveDate field. Hope this helps. I'm sure there is a more elegant way. -- Charles Kenyon Word New User FAQ & Web Directory: http://addbalance.com/word Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome! My criminal defense site: http://addbalance.com --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom. "TBoe" wrote in message ... Thanks for the info Charles. The reason for the text box was for formating issues. I guess I really don't need them. Next to the date is a sentence and I thought it would be easier if you had to enter a date then the test would not move. "Charles Kenyon" wrote: Why the text box? Generally fields in text boxes are not a good idea, and it makes the programming a lot more tricky. To get you started on handling a bunch of files, you might want to look at http://word.mvps.org/FAQs/MacrosVBA/BatchFR.htm which is on doing a replace on all files in a directory. In your case it would be relatively simple to adapt this to replace all DATE codes with SAVEDATE codes, which may not be what you want. -- Charles Kenyon Word New User FAQ & Web Directory: http://addbalance.com/word Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome! My criminal defense site: http://addbalance.com --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom. "TBoe" wrote in message news I have about 50 Word documents that I have to change 4 date fields to SaveDate format. I wanted to record a macro to delete the date, create a text box, and install the SaveDate field. Not being too familiar with macros, can this be accomplished? I tried to record the macro but it won't let me delete text or create a new line. The doc is not protected. Am I missing something? The mouse cursor has the tape icon on it but I really cannot do any editing. Is this nomal? TY |
#5
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Macro question
Great! Thanks for all your help Charles. I'll give it a try.
Terry "Charles Kenyon" wrote: A table would do the same thing. The thing about text boxes is that they are not in the same "layer" of the document as your regular text. It adds a big level of complexity. If you want something in a margin, you could put it in a frame (which acts a lot like a text box, but is still in the text layer). The following code creates a frame with a SaveDate field for the left margin. Sub Macro6() ' ' Macro6 Macro ' Macro recorded 4/13/2006 by Charles Kyle Kenyon ' With Selection .Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _ "SAVEDATE \@ ""d-MMM-yy"" ", PreserveFormatting:=False .MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend ActiveDocument.Frames.Add Range:=Selection.Range With .Frames(1) .Select .TextWrap = True .WidthRule = wdFrameExact .Width = InchesToPoints(0.8) .HeightRule = wdFrameAuto .HorizontalPosition = wdFrameLeft .RelativeHorizontalPosition = wdRelativeHorizontalPositionPage .VerticalPosition = InchesToPoints(0) .RelativeVerticalPosition = wdRelativeVerticalPositionParagraph .HorizontalDistanceFromText = InchesToPoints(0.1) .VerticalDistanceFromText = InchesToPoints(0) .LockAnchor = False End With .Collapse .ParagraphFormat.Alignment = wdAlignParagraphCenter .TypeText Text:="Saved" .TypeParagraph End With End Sub It is very sloppy, based on recording. Run it to get a frame. Adjust the formatting of the frame and the field until they are to your liking. Save this as an AutoText entry. Then, write your code to find date fields and in place of the date field insert the Autotext entry, which will be the framed SaveDate field. Hope this helps. I'm sure there is a more elegant way. -- Charles Kenyon Word New User FAQ & Web Directory: http://addbalance.com/word Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome! My criminal defense site: http://addbalance.com --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom. "TBoe" wrote in message ... Thanks for the info Charles. The reason for the text box was for formating issues. I guess I really don't need them. Next to the date is a sentence and I thought it would be easier if you had to enter a date then the test would not move. "Charles Kenyon" wrote: Why the text box? Generally fields in text boxes are not a good idea, and it makes the programming a lot more tricky. To get you started on handling a bunch of files, you might want to look at http://word.mvps.org/FAQs/MacrosVBA/BatchFR.htm which is on doing a replace on all files in a directory. In your case it would be relatively simple to adapt this to replace all DATE codes with SAVEDATE codes, which may not be what you want. -- Charles Kenyon Word New User FAQ & Web Directory: http://addbalance.com/word Intermediate User's Guide to Microsoft Word (supplemented version of Microsoft's Legal Users' Guide) http://addbalance.com/usersguide See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome! My criminal defense site: http://addbalance.com --------- --------- --------- --------- --------- --------- This message is posted to a newsgroup. Please post replies and questions to the newsgroup so that others can learn from my ignorance and your wisdom. "TBoe" wrote in message news I have about 50 Word documents that I have to change 4 date fields to SaveDate format. I wanted to record a macro to delete the date, create a text box, and install the SaveDate field. Not being too familiar with macros, can this be accomplished? I tried to record the macro but it won't let me delete text or create a new line. The doc is not protected. Am I missing something? The mouse cursor has the tape icon on it but I really cannot do any editing. Is this nomal? TY |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
FilePrint macro didn't work after all... | Microsoft Word Help | |||
Macro doesn't work | Microsoft Word Help | |||
Macro Button Won't Stay on Toolbar | Microsoft Word Help | |||
Save As is not working due to macro security settings | Microsoft Word Help | |||
2000 to 2002 macro and "Could not open macro storage" | Mailmerge |