Archive for the ‘Software’ Category

Windows Live Writer Blogs Easier

April 15, 2009

Today I’m using Windows Live Writer to write my blog. Nothing against the WordPress UI, but I think I might prefer the Windows Live Writer UI. It’s a full desktop GUI, similar to Microsoft Word. It does instant red underlines for spell checking, let’s you select categories and tags for each post easily, clearly shows each post’s status (draft, published, etc.), gives you themes (though the program tried to download my WordPress theme and failed), has full WYSIWYG preview view and source view, and integrates easily with many blogging sites including Windows Live Spaces (of course), Blogger, WordPress, TypePad, and SharePoint blogs.


Function to Convert TextRange to TextRange2 Objects and Vice-Versa

March 13, 2009

PowerPoint 2007 introduced the TextRange2 object which enhances the features of the TextRange object.

You may find the need to switch from a TextRange object to a TextRnge2 object because of the enhanced features available there. Conversely, you may wish to switch from a TextRange2 object to a TextRange object so you can use the more traditional features available there. Let’s get into the code…

' Convert from TextRange to TextRange2.
Function TextRangeToTextRange2(TextRange As PowerPoint.TextRange) As Office.TextRange2
    With TextRange
        Set TextRangeToTextRange2 = .Parent.Parent.TextFrame2.TextRange.Characters(.Start, .Length)
    End With
End Function

I had a need to make extensive use of the new properties of the TextRange2 object. However, I had some legacy code which made use of the Font.Color and Font.Underline properties. Well, surprise, surprise, those properties are not available in the Font2 object. I wanted a simple solution, so I wanted to go from a Font2 object to a regular Font object.

The best way to do this is to make use of my function TextRange2ToTextRange. Here is some sample code:

Sub SetUnderline(TextRange2 As Office.TextRange2)
    ' TextRange2.Font.Underline = msoTrue would not work.
    ' This does not work because TextRange2's Font property is a Font2 object.
    ' The Font2 object has UnderlineColor and UnderlineStyle properties,
    ' not the old-style Underline property.
    ' Instead we use the conversion function:
    TextRange2ToTextRange(TextRange2).Font.Underline = msoTrue
End Sub

Similarly, the Color property is not a member of Font2, so if you want to set just a plain-old RGB color, you can use the function:

Sub MakeRed(TextRange2 As Office.TextRange2)
    TextRange2ToTextRange(TextRange2).Font.Color = vbRed
End Sub

PowerPoint 2007 TextFrame2 is member of Office, not PowerPoint

March 1, 2009

The title says it all – PowerPoint 2007’s TextFrame2 object (and its associated objects TextRange2 and ParagraphFormat2) is a member of the Office library, not the PowerPoint library. That means that if you want to fully declare it, you must refer to it as Office.TextFrame2, not PowerPoint.TextFrame2.
You can verify all this in the Object Browser in the VBA IDE by hitting F2 and searching for the classes.

PowerPoint 2007 Indent Levels

February 16, 2009

Yes, I’ve confirmed that PowerPoint 2007 has 9 Indent Levels, unlike the 5 in previous versions.
Additionally, you can change indentation on a paragraph basis. On older versions, indentations were set only for the indent level, and individual paragraphs needed to conform to one of the preset levels.
To access these new features in VBA, you must use the TextFrame2 object hierarchy instead of the regular TextFrame hierarchy. When using the TextFrame2 hierarchy, all the additional features open up to the API for you.

How Many Ruler Indent Levels Does PowerPoint Have?

February 12, 2009

We’re investigating today how many ruler indent levels Microsoft PowerPoint allows per shape. Some say 5, some say 9. It may vary from version to version. I’ve tried it on PowerPoint 2002 and it’s 5 there.
I’ve verified this by creating a slide, typing some text on a bullet, then clicking the Increase Indent button multiple times. It allows me to click it 4 times before the button grays out. I can then decrease 4 times before the Decrease Indent button grays out.
I’ve also verified this in VBA by going into the Immediate window in the Visual Basic IDE and typing:
The response is 5.
I’ve heard reports that the value is 9 in PowerPoint 2007. I have not verified this, not have I checked in 2003.
However, even the Microsoft documentation on 2007 says it’s five – you can check here:
RulerLevels Object [PowerPoint 2007 Developer Reference]
Will someone solve the mystery? I may just have to try it on 2007 myself. Stay tuned…