Why oh why

Gah! Rant time. Yesterday, I found myself in the position of having to detach some PowerPoint files from a document to a specific location on users’ hard drives, then have the code fire these documents up. Stage 1, the user’s home directory in Win2k / Win XP was easy. I dug out a wee API function (called GetUserName funnily enough) and Bob was my uncle in creating the path in which to detach the files. So far, so good. Stage (2): how best to launch the files? I tried Shell to no avail. I was trying to fire up PowerPoint, but also provide it with the path to the specific file. Now in Windows, you’d just use Run and type in something like:

powerpnt.exe c:\your path goes here\file.pps

No joy with Shell though. For one thing, it didn’t like an exe without an absolute path — fair enough — and for another I just could not pass in the file I wanted to open for love nor money. I was quoting and bracing here there and everywhere. Nope, couldn’t do it.

I was just considering querying the registry to get a definite location for the exe when, ding! I figured I’d use COM instead. Shell was never the ideal choice, as our users could have PowerPoint installed in different locations (especially with our mixed environment). However, COM doesn’t care about the physical location of the exe. “Splendid,” I thought, “all I have to do is something like this:”

Set appPP = CreateObject("PowerPoint.Application")

Oh no, not so simple. You can’t have a generic object like “PowerPoint”. It has to have version with it (“Application.Powerpoint.9” for Office 2000, “Application.Powerpoint.10” for Office XP I worked out). How pants is that? Instantiating an Excel application object (for example) doesn’t require this. So, my code works, but it has to test for the version of PowerPoint installed, thus:

' // Assume Office 2000 is the default
Dim appPP As Variant
Set appPP = CreateObject("PowerPoint.Application.9")

' // Raises an automation error in Office XP
If Err = 208 Then
   Set appPP = CreateObject("PowerPoint.Application.10")
   Resume Next
End If

Urgh. What a crappy implementation. Anyone else come up with nicer ways of doing stuff like this they could share? OK, so the solution presented here works fine in our environment, but… it offends my aesthetic sensibilities!

Further reading: Follow up to why oh why.


  1. Hi, I wrote a class to modify Office Document properties e.g. Title Comments custom fields. Theres a fair bit of office automation code in it to deal with Word Excel Powerpoint. You might want to download the sample code at: link

    Not tested it on Office XP yet but it may prove useful.

    john marshalljohn marshall#

  2. Great, thanks for the link John. I just wish MS could be a little more consistent! I've automated Word and Excel with no real issues… this just seems odd to me. Oh well.Ben Poole#
  3. Would you have to call powerpoint first or can't you just launch the ppt file (which should launch powerpoint)… just curious.
    -ChrisChris Toohey#
  4. COM requires that you create the application object, and then you can call methods etc. on it. You can't just open a file. Shell requires that you kick off an exe or batch file. Then of course there's formula, but I had to use Lotusscript to cover the other bits of code.Ben Poole#
  5. Ben, Thanks for the post. I've used LotusScript to automate a fair number of tasks in Excel and Word (and Notes from Excel, Access, etc) - hadn't messed with LS to PowerPoint - and had not had to bother with the version numbers. BUT…I remeber Rocky Oliver mentioning at a DevCon last year that Office XP changed a LOT of the guts of Office, and therefore the LotusScript code one might have already had in production. I now have a to-do: test my old code with Office XP. Crap! But I'd rather find out about it this way than via a user call after an upgrade of their Office install. <sigh>
    JoeJoe Litton#
  6. Great post! Working with M$ is one of the toughest things about using Notes. Now, please help out a yankee with the term 'pants'. Like in your post where you say "How pants is that?" Where does it come from and what does it mean?
    -thanksChris Harvey#
  7. Joe, I thought XP was the culprit too, until I realised that Application.Excel still works just fine… for some reason, only PowerPoint requires the version number thing. All I can think of is M$ must have buggered about with PowerPoint's implementation of COM too much over the years…!

    Chris: pants. The British "pants" refers to a gentleman's underwear rather than his trousers, as you probably know. When we say something is "pants" over here, it's a colloquialism for expressing our dissatisfaction with that something ;-)Ben Poole#

  8. LOL - hey ben while ur at it, how about "Bob was my uncle"?jonvon#
  9. Meh heh, I wondered if anyone would catch that one. "Bob's yer uncle" = "and there you have it". Make sense?


    Thought not… :-)Ben Poole#

  10. very nice. a new one for my growing collection of benpooleisms. can't wait to use that one! loljonvon#
  11. Hum, nice thread boys. Good benpooleisms too ;o)

    OK, back into your problem Ben, I can't see the real problem by using Shell.

    I had to do the same weeks ago to download an .html attached to a document, and what I did was, on the PostOpen even I detached the document to C:\, so I had a file like C:\myfile.html, then I needed to open the default browser, then I only did was invoking the file and the OS looks for the right app to launch the file. In case of html files, it uses the default browser and in case of *.pps or *.ppt files it will open , with no doubt, powerpoint no matter wich version you have. I hope it helps you.


    Alex Hernandez#
  12. Yup, that often used to work for me in the past (if memory serves), and I did try it, but no go. At least, not on my two machines, and if the solution isn't water-tight, then… argh!Ben Poole#
  13. Try this: link Just something I dug out of my archive…

    - Julian Julian Robichaux#

Comments on this post are now closed.


I’m a software architect / developer / general IT wrangler specialising in web, mobile web and middleware using things like node.js, Java, C#, PHP, HTML5 and more.

Best described as a simpleton, but kindly. You can read more here.