![]() |
#1
|
|||
|
|||
![]()
Utilized the forums before but never posted. I've done some excel macros but not certain of the subtle difference between the two. So here's the scenario.
I have a folder that contains about 100 word documents. I'd like the macro to go to this folder select the first file, open it, and search for the ending dates of any month (ie January 31, February 28, March 31...etc), and change it to a specified ending (ex November 30). The specifying process can be handled either through a msg box or through manually editing one line of the code monthly. I'm ok with either. After the macro has opened and edited the document I'd like it printed in adobe to a specified directory. After its done all that I would like the macro to loop on to the next file in the folder containing the word documents. Sorry if this sounds like someone with a hand out, I'm in a bind and its the best way I know to explain my dilemma. Here is a sample of what I recorded. It is the find and replace portion. The problem I'd like to work around is having one line be edited that would removed the need to place in "Done" for every occurrence. From there its a looping and printing macro and I'm not certain of how to do that in word. Thanks in Advance Code:
Sub Macro3() ' ' Macro3 Macro ' ' Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = "January 31" .Replacement.Text = "Done" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll With Selection.Find .Text = "February 28" .Replacement.Text = "Done" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll With Selection.Find .Text = "March 31" .Replacement.Text = "Done" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll With Selection.Find .Text = "April 30" .Replacement.Text = "Done" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll With Selection.Find .Text = "May 31" .Replacement.Text = "Done" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll With Selection.Find .Text = "June 30" .Replacement.Text = "Done" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Selection.Find.Execute Replace:=wdReplaceAll With Selection.Find .Text = "July 31" .Replacement.Text = "Done" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll With Selection.Find .Text = "August 31" .Replacement.Text = "Done" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll With Selection.Find .Text = "September 30" .Replacement.Text = "Done" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll With Selection.Find .Text = "October 31" .Replacement.Text = "Done" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll With Selection.Find .Text = "November 30" .Replacement.Text = "Done" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll With Selection.Find .Text = "December 31" .Replacement.Text = "Done" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll End Sub Last edited by macropod; 11-26-2013 at 07:30 PM. Reason: Added code tags & formatting |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
tchase01 | Word VBA | 3 | 03-01-2012 04:03 PM |
![]() |
Yamaha Rider | Word VBA | 2 | 02-07-2012 05:33 PM |
![]() |
Nano07 | Word VBA | 2 | 11-02-2011 05:14 AM |
![]() |
Catalin.B | Excel Programming | 2 | 09-08-2011 11:37 PM |
![]() |
markg2 | Word | 3 | 12-26-2010 04:27 PM |