[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 487
  • Last Modified:

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
0
FaheemAhmadGul
Asked:
FaheemAhmadGul
  • 2
  • 2
1 Solution
 
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
 
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now