Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
Ben Ben is offline
external usenet poster
 
Posts: 54
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Ben Ben is offline
external usenet poster
 
Posts: 54
Default 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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
adding a date using a selectable calendar gasbill3 Microsoft Word Help 1 May 19th 08 08:46 AM
Pop-up Calendar won't insert date into document JFREE223 Microsoft Word Help 6 March 4th 08 01:22 PM
How do I change calendar date range? Dettee Microsoft Word Help 0 August 29th 07 02:46 AM
Specific formatting of the date Wowbagger New Users 3 August 2nd 05 11:46 PM
date picker calendar plautare Microsoft Word Help 1 March 16th 05 11:07 PM


All times are GMT +1. The time now is 03:33 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"