Guest post: Excel add-ins tutorial

First, I would like to thank Mary for giving me this opportunity to introduce my first Excel add-in on her website. It is an excellent programming resource.

My purpose in this blog entry is to describe the Data Filter Tool, an add-in I created for Microsoft Excel, as well as discuss some steps you can take to make sure your Excel add-in works properly.

This add-in does one thing: it filters a table of data and copies or moves matchingrows to a new workbook. For example, if you have a list of addresses in Excel, this add-in lets you filter by state and copy (or move) all the rows matching a specific state to a newly created workbook. Headers are always copied, even if you select the Move option, to preserve headers in the original data. It preserves formatting of the original data (bold, italic, etc) but copies values, not any underlying formulas. So I don’t recommend you use this tool if your data contains formulas; it’s mostly for tabular data like addresses, contact information, etc.

The dialog box is devastatingly simple: you just select the range to be filtered, the column and unique data item to base the filter on, select what option you want (Copy or Move) and then click ‘Apply’.

Let’s peek under the hood to see how the add-in operates, and hopefully that will give you some idea of how to create your own add-ins.

The first thing we do is some start-up checks to make sure we are in the right environment. Please note that some of the code I will demonstrate actually comes from “Microsoft Excel 2000 Power Programming with VBA”, written by John Walkenbach, ISBN 0764532634. We check the OperatingSystem Property of the Application Object to make sure we are in a version of Windows.

Function WindowsOS() As Boolean

If Application.OperatingSystem Like “*Win*” Then
WindowsOS = True
Else
WindowsOS = False
End If

End Function

Notice that even though the default value of a Boolean variable is False, I never assume that this will work properly so I always explicitly give a variable a value. We use this code in the Workbook_Open() event of the ThisWorkbook module as such.

If WindowsOS = False Then
MsgBox “This add-in is for Windows OS only.”, vbCritical
ThisWorkbook.Close False
Exit Sub
End If

This will close the add-in if someone tries to open it in a non-Windows setting. If your code is only intended for Excel 2000 or later, test for version compatibility with this code:

If Val(Application.Version) < 9 Then
MsgBox “This add-in will only work in Excel 2000 or later.”, vbOKOnly
ThisWorkbook.Close False
Exit Sub
End If

Before adding a menu item to the Data>Filter Menu, we always try to delete the menu, in case Excel did not close properly and the Workbook_BeforeClose Event was not able to run. I set an object reference to the Filter Menu like this:

Dim cb As CommandBarControl
Set cb = Application.CommandBars(“Data”).FindControl(ID:=30031)

Then we delete the menu, using an ‘On Error’ Statement to skip any errors, in case themenu item doesn’t exist, which is exactly what we want.

On Error Resume Next
cb.Controls(“Data Filter Tool”).Delete
On Error GoTo 0

If we passed all our startup checks, the add-in is installed and allowed to run.

In this post I showed you my new add-in and demonstrated some techniques for securing your own code. Hopefully you can use some of these techniques in your own add-ins.

To download the Data Filter Tool, visit http://www.codeforexcelandoutlook.com/DataFilterTool.zip
and of course check out my site at http://www.codeforexcelandoutlook.com/.

Enjoy,
JP

Flat File Blogging with FlatPress

If you’re into blogging and host your own blog, you are aware of the need for MySQL databases when you install most blogging platforms, and this is because most blogging programs, and indeed most content management systems store their data in a database. This is generally not a problem because most web hosts offer MySQL databases. But there are situations where you may not have or want to use a database.

Flatpress is a standard-compliant multi-lingual extensible blogging engine which does not require a database to work. Better yet, it’s open source. FlatPress stores all of its content on text files and therefore you don’t need a MySQL database. Installing it is a breeze, and you can get several themes to work with. Theming is done with Smarty and PHP, and the Wiki on the official Flatpress site has some useful information on this and other topics. There are a good number of plugins available, including Akismet, Categories, Calender, etc. Flatpress also has the ability to use widgets using the blockparser plugin.

All in all, FlatPress looks like it’s worth exploring, and is something I will be looking at and playing with more.

Have you used or do you use FlatPress? Please share your thoughts and experiences with us.

Microsoft going Open Source?

I just read this from the BBC News website:

Microsoft has announced that it will open up the technology of some of its leading software to make it easier to operate with rivals’ products.
The technology giant is to publish key software blueprints on its website.
It also promised not to sue open source developers for making that software available for non-commercial use.

Are we talking Microsoft going open source on some of it’s products?
Here is the link to the full news article: http://news.bbc.co.uk/2/hi/business/7257411.stm

It will be interesting to see where this goes. The fact that they’re now handing free developer tools to students tells me that Microsoft has stepped up their efforts at getting more developers to work with and get used to the Microsoft Suite of tools. And their goal now is to get them when they’re still young. I suppose with all the free and open source solutions that are available, Microsoft is feeling the pressure and the cost, and they want

The World’s Thinnest Notebook

MacBook Air
Apple has released what they tout as the World’s Thinnest Notebook, and you can pre-order it now at the Apple Store.
This is the ad for their latest release:

[youtube:http://youtube.com/watch?v=GBCfW9-hjKI]

This video is bit longer but gives you a guided tour of the MacBook Air.

[youtube:http://youtube.com/watch?v=W7askBmF4_c]

I have to say it looks pretty sweet, and even though I’m not currently a Mac user, it definitely looks tantalizing enough to tempt even me!

Here are the tech specs from Apple’s website:

Size and weight
Height: 0.16-0.76 inch (0.4-1.94 cm)
Width: 12.8 inches (32.5 cm)
Depth: 8.94 inches (22.7 cm)
Weight: 3.0 pounds (1.36 kg)

Processing Capability
The MacBook Air comes with Intel Core 2 Duo processor with 4MB on-chip shared L2 cache running at full processor speed wit 800MHz frontside bus and 2GB of 667MHz DDR2 SDRAM onboard. The standard processer is 1.6GHz but there is the option to upgrade to 1.8GHz.

Graphics Capability
Most Mac Addicts like to know about the graphics capability, so the MacBook Air has a 13.3-inch (diagonal) glossy widescreen TFT LED backlit display with support for millions of colors. The supported resolutions are: 1280 by 800 (native), 1152 by 720, 1024 by 768, 800 by 600, 800 by 500, 720 by 480, and 640 by 480 pixels at 16:10 aspect ratio; 1024 by 768, 800 by 600, and 640 by 480 pixels at 4:3 aspect ratio; 720 by 480 pixels at 3:2 aspect ratio. The MacBook Air is endowed with an Intel GMA X3100 graphics processor with 144MB of DDR2 SDRAM shared with main memory. It has extended desktop and video mirroring which means it simultaneously supports full native resolution on the built-in display and up to 1920 by 1200 pixels on an external display, both at millions of colors.

Connectivity
The MacBook Air comes with built-in AirPort Extreme Wi-Fi wireless networking (based on IEEE 802.11n draft specification); IEEE 802.11a/b/g compatible, and built-in Bluetooth 2.1 + EDR (Enhanced Data Rate).

Pricing
This sweet baby has two pricing options:

  • $1799 (or $43/month with Apple financing) for the 1.6GHz model that comes with a 80GB 4200-rpm PATA hard drive
  • $3,098 (or $74/month with Apple financing) for the 1.8GHz model that comes with a 64GB solid-state drive

You can pre-order yours at the Apple Store today and be one of the first people to own the world’s thinnest notebook!

Happy New Year and Happy Coding in 2008

2007 is finally winding down, with everyone getting ready to welcome the new year.  It’s  been a full and busy year for me, and as always, life has taken away from the time to code and build projects.  But I did uncover a lot of interesting resources and stuff that have given me ideas for projects for the new year.   All I have to do now is make time and get the ball rolling.  One of my goals for 2008 is to do more of the things I enjoy for the heck of it, so here’s to more coding, more discovery, more ideas, and more more more fun.

Happy New Year and Happy Coding!!