Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / April 2006

Tip: Looking for answers? Try searching our database.

Microsoft Word

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
WadeB - 04 Apr 2006 17:08 GMT
At work I have password protected documents (I know the password). Each Day
Mon-Friday I need to add a date for the next day - except Friday when I need
to insert Mondays date. Is there a way to automate this so all I have to do
is click print when the document is opened? Not sure if this matters but, I
have about 70 different documents that I have to open and do this to everyday.

Thanks Wade
Dave Lett - 04 Apr 2006 17:53 GMT
Hi Wade,

Yes, you can automate this. Here's some sample code to get you started:

Dim dDate As Date
Dim oRng As Range
Select Case Weekday(Date)
   Case vbMonday, vbTuesday, vbWednesday, vbThursday
       dDate = Date + 1
   Case vbFriday
       dDate = Date + 3
   Case Else '''Sat. or Sun.
       ''' do nothing
End Select

Set oRng = ActiveDocument.Range
oRng.Collapse Direction:=wdCollapseEnd
oRng.InsertAfter Text:=vbCrLf & dDate

You have a lot of options for formatting your date. The last line above is
only one example. Here's another, very easy alternative:

oRng.InsertAfter Text:=vbCrLf & FormatDateTime(dDate, vbLongDate)

HTH,
Dave
> At work I have password protected documents (I know the password). Each
> Day
[quoted text clipped - 8 lines]
>
> Thanks Wade
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.