Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-19-2014, 07:11 AM
damaniam damaniam is offline Loop Macro to Edit Date Windows 7 64bit Loop Macro to Edit Date Office 2013
Novice
Loop Macro to Edit Date
 
Join Date: Nov 2013
Posts: 18
damaniam is on a distinguished road
Default Loop Macro to Edit Date

I have a file containing multiple word documents. Each will contain the text "Month Year" (ex January 2014). I'd like the macro to open each file in folder and change the date to the previous month (compared to current) with proper year (i.e. December 2013 will become January 2014). As such the macro, if ran in 10 days, would change whatever month year combination to "February 2014".



Any help in this would be greatly appreciated. Thanks in advance
-J
Reply With Quote
  #2  
Old 02-19-2014, 02:51 PM
macropod's Avatar
macropod macropod is online now Loop Macro to Edit Date Windows 7 32bit Loop Macro to Edit Date Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

If you want the documents to always update to whatever the preceding month is, it would be better to replace the dates with a field code that does the updating, rather than relying on macros.

To see how to do this and just about everything else you might want to do with dates in Word, check out my Microsoft Word Date Calculation Tutorial, in the 'Sticky' thread at the top of the Word forum:
https://www.msofficeforums.com/word/...-tutorial.html
In particular, look at the item titled 'Calculate a month and year, using n months delay'. Do read the document's introductory material.

PS: I seem to recall providing you with a macro to change the dates as per your current request, in this thread: https://www.msofficeforums.com/word-...edit-date.html
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 02-19-2014, 03:50 PM
macropod's Avatar
macropod macropod is online now Loop Macro to Edit Date Windows 7 32bit Loop Macro to Edit Date Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Cross-posted at: http://social.msdn.microsoft.com/For...?forum=worddev
For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #4  
Old 02-20-2014, 07:16 AM
damaniam damaniam is offline Loop Macro to Edit Date Windows 7 64bit Loop Macro to Edit Date Office 2013
Novice
Loop Macro to Edit Date
 
Join Date: Nov 2013
Posts: 18
damaniam is on a distinguished road
Default

Sorry for the cross post will properly site next time.
I thought your name looked familiar. Thanks again for the previous help. The problem I have now is that similar setup (i.e. boat load of documents in a single folder), but now the date format is MMMM YYYY not MMMM DD, YYYY. Could you possible explain to me (while you doing it would fix my problem, offer no chance for learning) which variables are needing to be edited in the previous macro to yield the desired outcome.

Respectfully Grateful,
-J
Reply With Quote
  #5  
Old 02-20-2014, 02:27 PM
macropod's Avatar
macropod macropod is online now Loop Macro to Edit Date Windows 7 32bit Loop Macro to Edit Date Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

So, do the dates you're looking for this time include the day of the month, or only the month name & year? And what do you want the output expression to show? I recall we had a similar discussion last time ... If you're only processing month & year dates and there are also other dates in the document that have the day as well, what do you want to do about those?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #6  
Old 02-20-2014, 02:41 PM
damaniam damaniam is offline Loop Macro to Edit Date Windows 7 64bit Loop Macro to Edit Date Office 2013
Novice
Loop Macro to Edit Date
 
Join Date: Nov 2013
Posts: 18
damaniam is on a distinguished road
Default

The document contains month and year (December 2013) and the out put should be in the same format. There is only one occurrence per page of a date and it will be in the same format and without a separating comma.
Reply With Quote
  #7  
Old 02-21-2014, 12:01 AM
macropod's Avatar
macropod macropod is online now Loop Macro to Edit Date Windows 7 32bit Loop Macro to Edit Date Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

In that case, only a few minor changes to the previous code are required, being nothing more that deleting the day parts of the date references:
Code:
...
StrRep = Format(DateAdd("d", -1, CDate(Month(Now()) & "/1/" & Year(Now()))), "MMMM YYYY")
...
      .Text = "[ADJMO][abceghlmnorstuy]{2,7} [12][0-9]{3}"
      .Execute Replace:=wdReplaceAll
      .Text = "February [12][0-9]{3}"
      .Execute Replace:=wdReplaceAll
      .Text = "[AJSN][beilmnoprtuv]{4,8} [12][0-9]{3}"
...
Indeed, all of:
Code:
      .Text = "[ADJMO][abceghlmnorstuy]{2,7} [12][0-9]{3}"
      .Execute Replace:=wdReplaceAll
      .Text = "February [12][0-9]{3}"
      .Execute Replace:=wdReplaceAll
      .Text = "[AJSN][beilmnoprtuv]{4,8} [12][0-9]{3}"
could be reduced to:
Code:
      .Text = "<[JFMASOND][a-ceg-il-pr-vy]{2,8} [12][0-9]{3}>"
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #8  
Old 02-21-2014, 07:12 AM
damaniam damaniam is offline Loop Macro to Edit Date Windows 7 64bit Loop Macro to Edit Date Office 2013
Novice
Loop Macro to Edit Date
 
Join Date: Nov 2013
Posts: 18
damaniam is on a distinguished road
Default

Thanks so much for the help and the break down. I tend to be pretty handy with excel macros, but not so much with word macros.
Thanks again,
-J
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Loop Macro to Edit Date Loop Macro to Edit Date damaniam Word VBA 11 12-05-2013 08:28 AM
Loop Macro to Edit Date Macro to loop in Word Yamaha Rider Word VBA 2 02-07-2012 05:33 PM
Loop Macro to Edit Date WORD Macro - import picture - resize - position - page break - loop Nano07 Word VBA 2 11-02-2011 05:14 AM
Loop Macro to Edit Date Macro to loop in subfolders, change links, export xml data Catalin.B Excel Programming 2 09-08-2011 11:37 PM
Loop Macro to Edit Date 'Last edit date' markg2 Word 3 12-26-2010 04:27 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:20 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft