Thursday, June 30, 2005

Geek Code

The Geek Code is a succinct code that helps geeks identify themselves. In updating my geek code, I discovered that not much has changed since December of 2001.

This is what My Particular Geek Code looks like:

Version: 3.12
GE/CS d+(-) s: a+ C+++$ !U P+ L>++ E+>+++ W++(--) N !o K- w++(---) !O !M !V !PS !PE Y+ !PGP t !5 X-- R tv-- b++ DI+++ !D G e++>+++ h---- r+++ y?

More Outlook VBA: Toggling Grouping

In Am I Lazy or What? I described code that I wrote to add one of four signatures to an email message.

On Tuesday, I got tired of navigating the bowels of Outlook's menu system just to briefly turn grouping off and on. Grouping is a new, nifty feature in Outlook 2003.

So I wrote the following code to toggle grouping, and I customized my toolbar to add a button that invokes it. The code uses the XML property of the View object. The XML property is very cool. It looks like I can do a lot with it.

Sub ToggleGrouping() ' (c) 2005 Luddite Geek
' Provide a way to toggle item grouping.
' 06/28/05 Created.

Dim myOlApp As New Outlook.Application
Dim myOlExp As Outlook.Explorer
Dim myOlView As View
Dim strView As String
Dim i As Integer, j As Integer, n As Integer

Set myOlExp = myOlApp.ActiveExplorer
Set myOlView = myOlExp.CurrentView
strView = myOlView.XML
i = InStr(1, strView, "<arrangement>")
j = InStr(i, strView, "<autogroup>")
i = j + Len("<autogroup>")
n = CInt(Mid(strView, i, 1))

If n = 0 Then
Mid(strView, i, 1) = 1
ElseIf n = 1 Then
Mid(strView, i, 1) = 0
End If

myOlView.XML = strView

End Sub

The code on this page is provided free of charge. The author assumes no liability for any undesired effects it might have. Users may freely distribute the code only if this disclaimer is included. Users may not claim the work as their own.

Wednesday, June 15, 2005

Marketing + Technology = Featuritis

While I was desperately trying to find a way to avoid the heat on Sunday, Kathy Sierra was writing Featuritis vs. the Happy User Peak, a great companion piece to my Technology as Marketing article. Of course, Kathy has never read my blog, but I'm glad she posted her work. She did a much better job of getting my point across than I could!

Monday, June 06, 2005

Book Review: "A Short History of Nearly Everything"

At 560 pages, Bill Bryson's "A Short History of Nearly Everything" is anything but short. That is, until you consider that it really is the history of Everything.[1] In fact, Bryson's gift for understating book titles, as employed for "A Walk in the Woods" (in which he chronicles his attempt to hike the entire Appalachian Trail) is in full swing for this work.

It's a bit of a choppy book. But it's not easy to segue from the formation of, say, mountain ranges to the formation of Life, without sounding like a parody of Airplane.[2] Besides, we seem to lack quite a bit of hard evidence for most of Earth's history.

Otherwise I liked this history a lot. At times, I thought I was reading Douglas Adams, except that the scientists in an Adams novel wouldn't be as outlandish as the ones we owe our understanding of science to. The end, where Bryson discusses extinction, reminded me a great deal of Adams' "Last Chance to See."

But Adamseque examples appear even earlier on in the book. When Bryson discusses the 1918 flu epidemic, he describes an experiment in which 62 prison inmates are purposely exposed to people infected with the deadly strain. Not one even came down with the flu, yet the doctor who conducted the study became ill and died.

If you're the type who tends to worry about things that can go wrong, this book definitely will send you over the edge. Not only is our tiny planet the only place in the Universe we know of that can support our form of life, there are actually very few places on Earth that are hospitable. Even worse, though, is that the Earth is overdue for a spell of inhospitablility. And there'd be very little time to even prepare[3] and no escape. What are these things we're overdue for? A collision with a big asteroid, the blowing of a huge volcano in Yellowstone National Park, a magnetic reversal[4] are just a few of the things we have to look forward to. And it's not as if we can just run on over to Magrathea to pick up Earth Mark II if anything breaks.

[1] Everything scientific, that is. Imagine if he decided to include the history of religion, art and the Rolling Stones?

[2] Like when the guy says, "What happened? Tell me everything from the beginning." And the goofy guy says, "The Earth cooled. And then the dinosaurs came...."

[3] You might ask, "How would you prepare for an asteroid strike? Put a paper bag over your head? You can't do anything about it." Well, you could max out your credit cards buying all kinds of crazy stuff. You might bump into me at Walmart buying out their line of lava lamps.

[4] "What's so bad about a magnetic reversal? You can just turn your compass around 180 degrees when hiking," you might say. Actually the magnetic field shields us from harmful solar winds. The reversal might be a slow process, with a gradual decline of Earth's magnetic field to zero, and then a gradual increase in the strength of the opposite sense field. We might have enough time to build up an entire industry around radiation-proof clothing.

Wednesday, June 01, 2005

Am I Lazy or What?

Sunday's Dilbert cartoon might strike a nerve in some engineers. But why? A good engineer is a lazy engineer. The computer was invented because Charles Babbage got tired of calculating logarithms by hand.

Having written that, I'm proud to announce that I spent the last three hours automating something that used to take about five seconds. Yes, I know, but I do it a lot. Those five seconds add up. And now it only takes one second.

Here's the deal. My employer upgraded Outlook from 2000 to 2003 yesterday. But it didn't upgrade the other Office applications. I had used Word as my Outlook message editor, and I used its AutoText feature to add signatures to my emails. Since Outlook 2003 doesn't use Word 2000, I was forced to investigate Outlook's signature facility.

Outlook was thoughtful enough to allow for multiple signatures, and I thank the developers for that. But they failed to allow a proper method for selecting them with a keystroke. I was able to use keys, but look at the sequence involved: Alt-I S M x ENTER (where x is the first letter of a signature name.)1

So I wrote a macro that allows me to choose one of my four signatures from a listbox. So now it's either Alt-S ENTER (for the default signature) or Alt-S x ENTER, a savings of two or three keystrokes. And that means extra time for blogging. :-)

The code for this automation can be entered into two text files called module1.bas and userform1.frm. I recommend first adding the module and creating the user form in the VBA editor. Add a listbox and two command buttons to the form. Their names should be listbox1, commandbutton1 and commandbutton2, and the form should have the name userform1.

Here's what should go into module1.bas:
Option Explicit

' Supporting code for selecting message signatures.
' Copyright 2005 - 2006 by Luddite Geek,

Sub SelectSig()
Load UserForm1

End Sub

Function HTMLize(strBody As String) As String
' Replaces vbCrLf with <br />
HTMLize = Replace(strBody, vbCrLf, "<br />")

End Function

Here's what should go into userform1.frm:
Option Explicit

' Signature Chooser Code
' Copyright 2005 - 2006 by Luddite Geek,

Private Sub CommandButton1_Click()
' Based on

    Dim objItem As Object
    Dim thisMail As Outlook.MailItem
    'On Error Resume Next
    Set objItem = Application.ActiveInspector
    If Not objItem Is Nothing Then
        If objItem.CurrentItem.Class = olMail Then
            Set thisMail = objItem.CurrentItem
            If thisMail.HTMLBody = "" Then
                thisMail.Body = thisMail.Body & ListBox1.Text
                thisMail.HTMLBody = thisMail.HTMLBody & HTMLize(ListBox1.Text)
            End If
        End If
    End If
    Set objItem = Nothing
    Set thisMail = Nothing
    Unload UserForm1
End Sub

Private Sub CommandButton2_Click()
    Unload UserForm1

End Sub

Private Sub UserForm_Initialize()
UserForm1.Caption = "Luddite Geek Signature Chooser"
CommandButton1.Caption = "OK"
CommandButton1.Default = True
CommandButton2.Caption = "Cancel"
CommandButton2.Cancel = True

ListBox1.ColumnCount = 2

ListBox1.AddItem "Work"
ListBox1.List(0, 1) = vbCrLf & _
                      "Work Signature Line 1" & vbCrLf & _
                      "Work Signature Line 2" & vbCrLf & _
                      "Work Signature Line 3" & vbCrLf & _
                      "Work Signature Line 4"

ListBox1.AddItem "Home"
ListBox1.List(1, 1) = vbCrLf & _
                      "Home Signature Line 1" & vbCrLf & _
                      "Home Signature Line 2" & vbCrLf & _
                      "Home Signature Line 3" & vbCrLf & _
                      "Home Signature Line 4"

ListBox1.AddItem "Blog"
ListBox1.List(2, 1) = vbCrLf & _
                      "Blog Signature Line 1" & vbCrLf & _
                      "Blog Signature Line 2" & vbCrLf & _
                      "Blog Signature Line 3" & vbCrLf & _
                      "Blog Signature Line 4"

ListBox1.TextColumn = 2
ListBox1.ColumnWidths = "60;0"
ListBox1.ListIndex = 0

End Sub

1 The keystroke sequence in Outlook 2010 is worse. It's Alt-N AS S and then you need to use the arrow key to select from the list of signatures. Pressing the first letter of the signature name no longer selects it.

Edited on 2006-07-06 to add requested code samples.
Edited on 2013-08-05 to update link to Dilbert cartoon and footnote 1.