Macro to Enter Not Current Date but Yesterday's Date in the Word Document

I need help writing a macro (or code for the click event of a button on a form) , running which will enter not the current date but the Yesterday's date.
For example if I click on this button today (assuming that the current date is 06 November 2008)  then it will type yesterday's date in the following format
05 November 2008.
I would also appreciate help for the code that will enter the day before Yesterday's date in the currently active word document. So if the current date is 06 November, when run this macro will enter the following:
04 November 2008
Thank you for your help in anticipation
LVL 1
FaheemAhmadGulAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

game-masterCommented:

good morning!

i hope this will give u idea..
i tried this and it works fine with me..


Sub typeYesterdayDate()
   
    ActiveDocument.Select
    Selection.TypeParagraph 'enter
    Selection.TypeText Format(Now - 1, "dd MMMM YYYY")

End Sub

Sub typeDayBeforeYesterday()
    ActiveDocument.Select
    Selection.TypeParagraph 'enter
    Selection.TypeText Format(Now - 2, "dd MMMM YYYY")
End Sub



game-master
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
FaheemAhmadGulAuthor Commented:
Many thanks. Worked perfectly. I am extremely grateful. Regards - Faheem
0
FaheemAhmadGulAuthor Commented:
Many thanks. Worked perfectly. I am extremely grateful.
0
game-masterCommented:

im glad i could help..:-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.