I am using a word document, to document may daily tasks and doings. And as the good geek I am, I wanted to implement a macro in MS word to make a day entry at the punch of a short cut.
After playing alot with the anything-but-intuitive vb I finally finished the following macro:
Sub addEntry()
'' addEntry Macro' Macro recorded 4/7/2008 by kim' ' write headline ("Diario di bordo ") Selection.Font.Name =
"Courier New" Selection.Font.Bold = True
Selection.Font.Underline = True
Selection.TypeText Text:=
"Diario di bordo " Selection.InsertDateTime DateTimeFormat:=
"dd/MM/yyyy HH:mm:ss", _
InsertAsField:=False, DateLanguage:=wdItalian, CalendarType:= _
wdCalendarWestern, InsertAsFullWidth:=False
Selection.TypeParagraph
Selection.Style = ActiveDocument.Styles(
"Normal")
' add bold headline ("Should-does:") Selection.Font.Bold = wdToggle
Selection.TypeText Text:=
"Should-dos:" ' add point lists. Selection.TypeParagraph
Selection.MoveUp Unit:=wdLine, Count:=1
Selection.TypeParagraph
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.Style = ActiveDocument.Styles(
"List Bullet")
' if it is friday, add "Write Status report" to bullet list.today = Weekday(Date$, vbMonday)
If (today = vbFriday) Then
Selection.TypeText Text:="Write Status report"
End If
Selection.TypeParagraph
Selection.TypeParagraph
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.MoveLeft Unit:=wdCharacter, Count:=1
' remove type type. Selection.Range.ListFormat.RemoveNumbers NumberType:=wdNumberParagraph
End Sub
Which does exactly as I have described in the comments (the stuff in green). And produces the following in my diary.
Diario di bordo 01/07/2008 17:43:57
Should-dos:
·
·
(sorry the mess of HTML (if you look in "document source" of this HTML, its pretty ugly, but I just did a copy paste from Word).
If its a friday, it will add the "Write status report" to the list of "Should dos"