Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Open doc and go to end

Posted on 2009-02-24
4
Medium Priority
?
236 Views
Last Modified: 2012-06-27
Hello Experts,

I would like to know how I can add code to the on open event of a word doc:
go to the end
Add current date in this format: Tuesday, February 24, 2009

Thank you
0
Comment
Question by:Petrobras
  • 2
  • 2
4 Comments
 
LVL 5

Expert Comment

by:CalmSoul
ID: 23723049
Here you go
Sub Macro2()
 
    Selection.MoveDown Unit:=wdScreen, Count:=1
    Selection.EndKey Unit:=wdLine
    Selection.EndKey Unit:=wdLine
    Selection.MoveDown Unit:=wdScreen, Count:=3
    Selection.TypeParagraph
    Selection.MoveDown Unit:=wdScreen, Count:=1
    Selection.TypeParagraph
    Selection.InsertDateTime DateTimeFormat:="dddd, MMMM dd, yyyy", _
        InsertAsField:=False, DateLanguage:=wdEnglishUS, CalendarType:= _
        wdCalendarWestern, InsertAsFullWidth:=False
End Sub

Open in new window

0
 

Author Comment

by:Petrobras
ID: 23723365
Hi Calmsoul,

Thanks for the code.  I wonder if I can do this though for end of doc:
Private Sub Document_Open()
    ThisDocument.Bookmarks("\EndOfDoc").Select
   

End Sub

then insert your code for date:
 Selection.InsertDateTime DateTimeFormat:="dddd, MMMM dd, yyyy", _
        InsertAsField:=False, DateLanguage:=wdEnglishUS, CalendarType:= _
        wdCalendarWestern, InsertAsFullWidth:=False

End Sub

==========
Giving:
Private Sub Document_Open()
    ThisDocument.Bookmarks("\EndOfDoc").Select

 Selection.InsertDateTime DateTimeFormat:="dddd, MMMM dd, yyyy", _
        InsertAsField:=False, DateLanguage:=wdEnglishUS, CalendarType:= _
        wdCalendarWestern, InsertAsFullWidth:=False

End Sub

Let me know.  Thanks
0
 
LVL 5

Accepted Solution

by:
CalmSoul earned 2000 total points
ID: 23723633
try this
Private Sub Document_Open()
    ActiveDocument.Bookmarks("\EndOfDoc").Select
 
 Selection.InsertDateTime DateTimeFormat:="dddd, MMMM dd, yyyy", _
        InsertAsField:=False, DateLanguage:=wdEnglishUS, CalendarType:= _
        wdCalendarWestern, InsertAsFullWidth:=False
 
End Sub

Open in new window

0
 

Author Comment

by:Petrobras
ID: 23723932
that worked great!  Thanks!
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question