Thursday, 31 July 2008

Find dublicates when SQL is your friend

Just to remember it another day. If you want to find which elements there is more then one time.

FROM table
HAVING count(CODE) > 1

It helped me a lot, so I hope you, my reader can utilise it as well.

Tuesday, 1 July 2008

Add entry macro in my word document

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.Style = ActiveDocument.Styles("Normal")

' add bold headline ("Should-does:")
Selection.Font.Bold = wdToggle
Selection.TypeText Text:="Should-dos:"
' add point lists.
Selection.MoveUp Unit:=wdLine, Count:=1
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.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




(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"