Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Open Calendar to Specific Date
I have a weekly calendar (one week per page) in Word 2007. When Word opens,
it automatically opens to the first page. How do I program Word so that it opens to the current date/week (i.e. to the page with the week beginning June 14, 2009)? |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Open Calendar to Specific Date
On Wed, 10 Jun 2009 15:06:01 -0700, Ben wrote:
I have a weekly calendar (one week per page) in Word 2007. When Word opens, it automatically opens to the first page. How do I program Word so that it opens to the current date/week (i.e. to the page with the week beginning June 14, 2009)? That depends on whether the specific date is somewhere on that page, and in what format. The general idea is that you create a macro named AutoOpen (which runs automatically when the document opens), in which the macro does a Find for the date of the first day of the current week. If your dates are in the format you showed above, and if each page starts with Sunday's date, then the following macro will go to the beginning of the page that contains the current date (see http://www.gmayor.com/installing_macro.htm if needed). Sub AutoOpen() Dim startThisWeek As Date Dim searchTerm As String Dim rg As Range startThisWeek = Now While Not Weekday(startThisWeek) = vbSunday startThisWeek = DateAdd("d", -1, startThisWeek) Wend searchTerm = Format(startThisWeek, "MMMM d, yyyy") Set rg = ActiveDocument.Range With rg.Find .Text = searchTerm If .Execute Then rg.Select End If End With End Sub If you would rather go to the current date no matter where it is on the page, remove the three lines from "While" to "Wend". -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. |
#3
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Open Calendar to Specific Date
Thanks Jay. This worked great. I just had to change the date format because
it was different from what I originally wrote. |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
adding a date using a selectable calendar | Microsoft Word Help | |||
Pop-up Calendar won't insert date into document | Microsoft Word Help | |||
How do I change calendar date range? | Microsoft Word Help | |||
Specific formatting of the date | New Users | |||
date picker calendar | Microsoft Word Help |