VSTO & .NET & Excel

August 15, 2009

Check which Windows version is running

Filed under: .NET & Excel, VSTO & Excel — Dennis M Wallentin @ 12:51 pm

In the second edition of PED we introduce a new area; Creating Cross Version Applications. That is, to develop solutions that must run with all Excel versions and Windows versions using a single code base. I will not discuss how to code against different Excel versions. Instead I set focus on running .NET solutions on different Windows versions, i.e. Windows 2000/Windows XP and Windows Vista/Windows 7.  It should be noted that I have previously blogged how to check which Excel version that is installed.

With Windows 2000 and Windows XP we know that the user accounts are available in paths like:
C:\Documents and Settings\Dennis

In Windows Vista and Windows 7 the user accounts are located in  paths like:

Given this information we can rather easily code for different Windows versions in VB.NET. First we need to find out which Windows version that the targeting computers use. As the code shows below the namespace My.Computer once again comes to our rescue.

In the next step we retrieve the current user’s identity which is carried out by the SystemInformation namespace. Finally we put it together with the help from the StringBuilder namespace.

Code Windows Version and current user 1

When we run the code on a Windows Vista configuration we get the following information: 

Output when running on Windows Vista

When the User Access Control (UAC) is turned on (Windows Vista/Windows 7) we cannot access the c:\ root unless we run as administrator. But no matter the UAC status we can always access the current user’s folder system. In that way we can write and read files to the user’s folders in addition to the above.

Kind regards,


August 9, 2009

Excel Loader New Version Released

Filed under: Tools, XL-Dennis' freewares — Dennis M Wallentin @ 12:49 am

Excel Loader is a free standalone utility that let the user choose which add-ins should be loaded or not when launching Microsoft Excel.

I have updated the utility so it can run on Windows Vista and Windows 7 as well. The new version will also work with Excel 2010 once it’s out on the market. 

The next version of the tool will be completely rewritten as it will be developed on the .NET platform. In case You have any input about new features of the tools please let me know.

Below is a screen shot of its main window:

Excel Loader 1.5

For more information about the tool and to download it please visit: Download XL-Dennis Tools

Kind regards,

August 4, 2009

Connected to the network?

Filed under: .NET & Excel, COM Add-ins, VSTO & Excel — Dennis M Wallentin @ 1:37 am

It has been a while since I last made a post here.  But I intend to get up to speed and publish on a more regular basis. Anyway, on the .NET platform and with VB.NET we can rather easy check if the computer we work on is connected to a network or not.

To know that information allows us:

  • To run methods that update workbooks with the latest data.
  • Run network located templates and individual workbooks.
  • Load network based add-ins.

Technically we will be using the My namespace to find out if the computer is connected or not.  More specifically we will use the  My.Computer namespace which provides methods to control the computer’s hardware and the system software.  Among other things, it allows us to work with the file system, clipboard, Windows Registry network printers, network connection and keyboard & mouse.

The following snippet code shows how we can use it to determine if the computer is connected to a network.



Because the property isAvailable only indicates if there is a network available or not we need to make sure that there is a connection to the network we actually want to access. In order to do so we use the Ping function to insure that the wanted remote location is available.

Kind regards,

Create a free website or blog at WordPress.com.