October 2006 - Posts

Windows Live Writer BlogThis macro for Outlook 2007

If you use Windows Live Writer as your blogging tool and Outlook 2007 as your RSS aggregator then you maybe interested in this VBA macro. It will pull the necessary information from the currently selected RSS Item in Outlook and call the Windows Live Writer BlogThis API to create a new post.

Const FEED_URL = "http://schemas.microsoft.com/mapi/id/{00062041-0000-0000-C000-000000000046}/0x8900001F"
Const FEED_NAME = "http://schemas.microsoft.com/mapi/id/{00062041-0000-0000-C000-000000000046}/0x8904001F"
Const ITEM_URL = "http://schemas.microsoft.com/mapi/id/{00062041-0000-0000-C000-000000000046}/0x8901001F"

Sub BlogThis()
    Set liveWriter = CreateObject("WindowsLiveWriter.Application")
    
    If (liveWriter Is Nothing) Then
        MsgBox "It appears that Windows Live Writer is not installed"
        Exit Sub
    End If
    
    If (ActiveExplorer.Selection.Item(1).MessageClass <> "IPM.Post.Rss") Then
        MsgBox "The currently selected item is not a RSS Post"
        Exit Sub
    End If
    
    Dim rssItem As PostItem
    Dim pa As PropertyAccessor
    
    Set rssItem = ActiveExplorer.Selection.Item(1)
    Set pa = rssItem.PropertyAccessor
    
    feedUrl = pa.GetProperty(FEED_URL)
    feedName = pa.GetProperty(FEED_NAME)
    itemUrl = pa.GetProperty(ITEM_URL)
    itemTitle = rssItem.Subject
    itemContents = rssItem.HTMLBody
    
    liveWriter.BlogThisFeedItem feedName, itemTitle, itemUrl, itemContents, feedUrl, _
        authorMissing, autherEmailMissing, publishDateMissing
End Sub

See KC's post for adding this VBA macro as a toolbar button in Outlook or if you would prefer to add this on the RSS item context menu you could add the following to your default VBA project.

Sub Application_ItemContextMenuDisplay(ByVal CommandBar As Office.CommandBar, ByVal Selection As Selection)
    If (Selection.Count = 1 And Selection.Item(1).MessageClass = "IPM.Post.Rss") Then
        Set blogThisBtn = CommandBar.Controls.Add(Type:=msoControlButton)
        blogThisBtn.Caption = "Blog This in Live Writer"
        blogThisBtn.OnAction = "Project1.ThisOutlookSession.BlogThis"
    End If
End Sub

Enjoy!

CodeHTMLer plugin for Windows Live Writer

I've started using Windows Live Writer as my primary blogging tool. So far I like it. However, it was missing an easy way to insert highlighted code into posts. I know there are a few other plugins that can insert highlighted code, but since I'm the author of a syntax highlighting tool named CodeHTMLer I figured I needed to write my own plugin.

While writing the plugin I also updated CodeHTMLer a little and added a few more language definitions. CodeHTMLer now supports the following languages C#, C++, Java, JScript, VB.Net, XML, and Powershell. One cool thing about my CodeHTMLer plugin is that it supports changing and adding new language definitions. So if you don't like my default colors than change them, or if you want another language defintion add it (if you do add more languages feel free to send me the definition and I may add it to the default language set).

Thanks to Chris for doing some testing for me. Enjoy!

Posted by puzzlehacker | 1 comment(s)
Filed under: , , ,

Ways to shutdown/restart your computer via Remote Desktop.

I don't how many times I've needed to reboot a machine while accessing it over Remote Desktop. I usually just open a command prompt and type shutdown -t 0 -r to reboot. However, Raymond provides four ways to do this.

When you are connected to a workstation via Remote Desktop, the "Turn Off Computer" option changes to "Disconnect". But what if you really want to turn off the computer, hibernate it, or put it on stand-by?

Note: These tips work on Windows XP, but there is no guarantee that they will work in future versions of Windows.

One way to do this is to run Task Manager and select your shutdown option from the "Shut Down" menu.

Another trick is to click on the desktop and type Alt+F4. This will call up the shutdown dialog, where you get the usual shutdown options like "Shut down", "Shut down without installing updates", "Restart", "Stand by", and "Hibernate".

These next two tricks are documented and will continue to work in future versions of Windows:

If you're a command line person, you can run shutdown.exe, but that program supports only shutdown and restart; it doesn't do stand-by or hibernate. But the shutdown.exe program has a serious flaw: It requires you to have administrator privileges. If you are a limited user with shutdown privileges, the shutdown.exe program will complain. (Which means that I don't use it.)

Finally, if your computer isn't using Fast User Switching, you can type the Ctrl+Alt+End hotkey, which is the Remote Desktop version of Ctrl+Alt+Del and consequently takes you to a dialog where you can do various system-type things, among them logging off and shutting down.

[How do I shut down a workstation via Remote Desktop?]

I wonder about the shutdown.exe requiring admin privileges. I'm running as non-admin on my Vista machine and I know I've used the shutdown.exe to reboot the computer a number of times, then again maybe this has been fixed in Vista. Anyway I'm going to keep all these ideas in mind the next time I need to reboot a computer over Remote Desktop. Thanks Raymond.

More Posts