RibbonX bug – separator visible attribute

I believe that I’ve uncovered a bug in the implementation of the visible attribute of the separator element. Or rather, the fact that you cannot set the visible attribute to false.

The code I used to test this was as follows:

XML code for an Excel xlsm file:

  1. <customUI onLoad="captureRibbonUI"
  2. xmlns="http://schemas.microsoft.com/office/2006/01/customui">
  3. <ribbon>
  4. <tabs>
  5. <tab idMso="TabHome">
  6. <!--New Group on Home tab-->
  7. <group id="rxgrpCustom"
  8. insertBeforeMso="GroupClipboard">
  9. <!--Static separator-->
  10. <labelControl id="rxlctlIndicator01"
  11. label="Sep 1 -->"></labelControl>
  12. <separator id="rxsep01"
  13. visible="false"></separator>
  14. <!--Dynamic separator-->
  15. <labelControl id="rxlctlIndicator02"
  16. label="Sep 2 -->"></labelControl>
  17. <checkBox id="rxchkDynamic"
  18. label="Show Sep 2?"
  19. onAction="rxchkDynamic_click" />
  20. <separator id="rxsep02"
  21. getVisible="rxsepDynamic_getVisible" />
  22. <!--Debug Mode setting-->
  23. <checkBox id="rxchkDebug"
  24. label="Debug Mode"
  25. onAction="rxchkDebug_click" />
  26. </group>
  27. </tab>
  28. </tabs>
  29. </ribbon>
  30. </customUI>

Code in the Thisworkbook module:

  1. Private pRibbonUI As IRibbonUI
  2.  
  3. Public Property Let ribbonUI(iRib As IRibbonUI)
  4. 'Set RibbonUI to property for later use
  5. Set pRibbonUI = iRib
  6. End Property
  7.  
  8. Public Property Get ribbonUI() As IRibbonUI
  9. 'Retrieve RibbonUI from property for use
  10. Set ribbonUI = pRibbonUI
  11. End Property

Code in a standard module:

  1. Private bDebugMode As Boolean
  2. Private bDynamicSepVisible As Boolean
  3.  
  4. 'Set the RibbonUI to a workbook property for later use
  5. Private Sub captureRibbonUI(ribbon As IRibbonUI)
  6. bDynamicSepVisible = True
  7. ThisWorkbook.ribbonUI = ribbon
  8. End Sub
  9.  
  10. 'Callback for rxbtnDynamic onAction
  11. Sub rxchkDynamic_click(control As IRibbonControl, pressed As Boolean)
  12. If bDebugMode = True Then Stop
  13.  
  14. bDynamicSepVisible = pressed
  15. ThisWorkbook.ribbonUI.InvalidateControl ("rxsep02")
  16.  
  17. End Sub
  18.  
  19. 'Callback for rxsepDynamic getVisible
  20. Sub rxsepDynamic_getVisible(control As IRibbonControl, ByRef returnedVal)
  21. If bDebugMode = True Then Stop
  22.  
  23. returnedVal = bDynamicSepVisible
  24. Debug.Print "Separator visible property set to " & bDynamicSepVisible
  25. End Sub
  26.  
  27. 'Callback for rxchkDebug onAction
  28. Sub rxchkDebug_click(control As IRibbonControl, pressed As Boolean)
  29. bDebugMode = pressed
  30. End Sub

Upon saving all that and opening the file, you get a really ugly little group on the Home tab that looks like this:

bug_separator.jpg

Now, the interesting things here are that the first separator has it’s visible property set to false. So why is it showing? The second separator is hooked up to the “Show Sep 2?” checkbox to make it dynamic. Uncheck it and the separator will stay there. I only hooked both up as I wanted to check if having the attribute set to static or dynamic would make a difference.

Finally, the Debug Mode is just there to allow you to see that the code does trigger and step through it while firing if you want to.  (It also logs the value of the property to the immediate window, but this saves you looking there.)  The entire Debug Mode and debug.print section could be dropped from the example, but then the checkbox doesn’t appear to do anything. (As compared to doing something but being ineffective!)

I don’t know how much this attribute would even be used, but the fact is that it doesn’t work as advertised.  I’m going to log this one with Microsoft.  :)

Windows Update High CPU Usage on Windows XP

I got in to work this morning, set on getting some stuff done in a hurry, and was greeted with a computer that was running slower than molasses. Just terrrible. It turns out that a process called svchost.exe was consuming between 95% and 99% of my CPU, (somtimes as high as 100%,) which makes it pretty difficult to do any work.

Sadly, I’ve seen this before on my wife’s old Win XP PC, and spent a few hours trying to figure it out. After downloading some tools to analyze what services make up svchost.exe, it became evident that it was Microsoft Update that was consuming everything. I’m not sure what bug they introduced, when, or why it only affects some PC’s and not others. (I haven’t had any issues until today, but my wife’s started about 2 months ago.)

The only thing we seemed to be able to do to on Deanna’s machine to get past it was to walk away for a couple of hours. (Never timed exactly how long it took as I don’t enjoy watching Windows do nothing.) Needless to say, I don’t have that luxury at work. In fact, even reformatting her PC and starting again from a fresh WindowsXP install did not help!

After the reformat, I went hunting and did see some advice to uninstall Microsoft Update and resume using regular Windows Update. That, unfortunately, didn’t make a lick of difference when I tried it on my wife’s PC. What finally worked? I turned off Window Automatic Update.
Be aware that this must be set to Off, and not the setting to download/notify of updates. That leaves the process running, so doesn’t help. For the record, I’m not saying that doing this is the most secure thing to do, I just said it was effective. (In fact, as a system admin resonsible for managing 50 workstations, turning this off makes me feel a bit ill!)

At any rate, upon seeing the issue here, I again shut off Automatic updates. The problem immediately dissappeared, with the svchost.exe process dropping back down to 0% CPU use.

So if your Windows XP box suddenly starts running very slow, check the task manager and see what svchost.exe is doing. It may be much cheaper to try shutting of your automatic updates than upgrading to a new Vista machine.

And if anyone knows a way to fix this without turning off the automatic updates completely, I’d like to know about it. :)

Identifying your imageMso – Excel, Word & Powerpoint

A little background

A while ago, I blogged about the Excel 2007 Icon Gallery, which is available from Microsoft right here. It’s a useful tool when you’re trying to identify the imageMso that you’re after, no question… but there’s a problem… It’s only available in Excel. :(

Based on the information in my previous blog post, you’ll know that I’ve also turned Microsoft’s workbook into an add-in so that its always available to me. I’ve made some fair use of it in playing around with Ribbon modifications as well.

Last week I was writing up some stuff with Word, and I found myself flipping back over to Excel to look up the imageMso that I needed. This struck me as kind of silly, as I figured that it should be pretty easy to port this over to Word. I mean, really, that was the whole point behind going to XML and consistent structure, right? So I decided to do it. In fact, I built a version for Word and Powerpoint. Both they and the Excel version are included in the zip file attached to the bottom of this post. I may also add an Access version later, but you’ll have to hold on for that one.

Before I started on porting this to Word & Powerpoint though, I took on some comments from Zack Barresse (both from the aforementioned blog post feedback as well as a VBAX post) and decided to implement them as well. I changed the userform a little bit and added Zack’s ultimate lazy factor in; having the button automagically copy the imageMso name to the clipboard. Just because I could, I also added the option to close upon copying, as I figured that someone may not always want to copy and exit. The value of the checkbox is stored in the registry, so you only have to set it once.

Here’s a picture of the new userform in action:

imagemsoindent.png

So then came the fun part…

Excel

Now, for me Excel was pretty easy as I’ve built more add-ins than I can remember. In this case even easier, as I was only really adjusting work someone else already did. If you’ve never installed an Excel add-in before though, you simply:

  • Download the zip file and extract it to your computer somewhere.
  • I’d suggest copying the Office2007IconsGallery.xlam file from that location to store it in the addins directory which can be found at:
    • Vista –> C:\Users\Username\AppData\Roaming\Microsoft\AddIns
    • XP –> C:\Documents and Settings\Username\Application Data\Microsoft\AddIns
  • Open Excel 2007
  • From the Office menu, choose Excel Options|Add-Ins|Go…
  • Check the box next to Office2007IconsGallery, then OK

Now, check the Developer tab for this:

icongallery.png

No big secret here. Just click a gallery, select an image, and you’ll get the userform that I displayed above.

Word

Now Word was a little more entertaining than Excel, as I’d never built and addin for Word.

Here’s the process I used to convert it:

  • In Excel, I exported the userform and code module to the desktop
  • I created a new Word .dotm (Macro enabled template) file, and imported the userform and code module
  • After saving the file and closing both Word and Excel, I opened the Excel add-in in the CustomUI editor
  • I copied all the XML code from the Excel add-in, and closed the file
  • Finally, I opened up the Word dotm file in the CustomUI editor, pasted all the XML, saved it and closed it.

Honestly, that was the easy part. As soon as I opened the file again, my group was there and it worked. The problem now was deployment…

I’d just assumed that you could dump it in to Normal.dotm, and away you go. While that works, it’s a really bad idea, I found out, as the XML (at a minimum) goes with whatever documents that you create off of the normal template. That’s not really cool, as I didn’t really want to send that modification to everyone, so I needed a different way.

Now, Word doesn’t use Add-ins, per se, but rather a form called a Global Template. While I’d heard of these, I’d never really built one in the past, as I’ve never created any Word utilities that I needed to share. Basically, to make your template into a global template, you just drop it in Word’s STARTUP directory… that’s it. In all honesty, this was a bit of a surprise, as if you do this in Excel, the file opens and is visible. Word essentially treats all its templates stored there as add-ins, so there you go.

So to recap, if you want to use the Word version of the file:

  • Download the zip file and extract it to your computer somewhere.
  • Copy the Office2007IconsGallery.dotm file to:
    • Vista –> C:\Users\Username\AppData\Roaming\Microsoft\Word\STARTUP
    • XP –> C:\Documents and Settings\Username\Application Data\Microsoft\Word\STARTUP
  • Open Word, and it’s already there on the Developer tab

There is no checking of boxes required to get this to load or anything. It will just be there when you start Word up, and none of your new documents will inherit its XML code base. :)

Powerpoint

Probably the most mystifying of the applications to work with in this regard is Powerpoint.

Here’s what I did first, much to my chagrin…

  • In Excel, I exported the userform and code module to the desktop
  • I opened Powerpoint, imported the userform and code module into the file and then saved it as a Macro Enabled Template (ppam) file
  • After saving the file and closing both Powerpoint and Excel, I opened the Excel add-in in the CustomUI editor
  • I copied all the XML code from the Excel add-in, and closed the file
  • Finally, I opened up the Powerpoint ppam file in the CustomUI editor, pasted all the XML, saved it and closed it.
  • I opened Powerpoint and tried to install it as an add-in, only to be told it wasn’t a valid file

Grr…

I double-clicked the file from Windows Explorer, and it opened up just fine with my customizations. But when I closed Powerpoint and re-opened it, I could not get the add-in to load automatically.

It turns out that you need to add a little code to your add-in to get it to register itself for auto-loading. So armed with this code, I opened up the file, jumped in to the VBE… and it was not there???

So a big note to everyone who is building their first add-in in Powerpoint… SAVE A BACKUP COPY TO A REGULAR FILE FIRST! It looks like once you’ve converted to an add-in, that’s it. One shot, and you’re done. So back I went, repeating all the above steps, but this time with a regular Macro Enabled (pptm) file. In addition, I also added the following code to get it to register for auto-loading:

  1. Sub Auto_Open()
  2. ' Get a reference to your add-in.
  3. With AddIns(AddIns.Count)
  4. ' Create the registry key in HKEY_CURRENT_USER.
  5. .Registered = msoTrue
  6. ' Set the AutoLoad value in the registry.
  7. .AutoLoad = msoTrue
  8. ' Makes sure that the add-in is loaded.
  9. .Loaded = msoTrue
  10. End With
  11. End Sub

So with the above code in the standard module with the RibbonX callback code, I saved the file (in the pptm format), then saved it as an add-in again. Nothing really seems to happen at that point really except you get prompted for the directory to save it in, of course. (Oh! By the way, Powerpoint Add-ins go in the Add-ins directory.) But once saved, you’re back staring at your original file again, with no indication that the add-in ever really loaded. At any rate, I then closed down Powerpoint, browsed to the add-in location in Windows Explorer, and launched it from there. It works like a breeze now.

Fortunately for you, I’ve included the powerpoint add-in in the zip file as well. To use it:

  • Download the zip file and extract it to your computer somewhere.
  • Copy the Office2007IconsGallery.ppam file to:
    • Vista –> C:\Users\Username\AppData\Roaming\Microsoft\AddIns
    • XP –> C:\Documents and Settings\Username\Application Data\Microsoft\AddIns
  • Double click the file in Windows Explorer, and it will open Powerpoint for you and register the file
  • Browse to the Developer tab to see it waiting for you

After you’ve followed these steps once, you don’t have to worry about lauching the file that way again. It’s registered to load automagically every time you launch Powerpoint.

Some conclusions

Whether you feel that Microsoft got it right with the Ribbon or not, I think you’d have to agree that deploying an identical UI enhancement across multiple applications would be complicated to say the least. This was actually remarkably easy, in truth. The biggest complication for me was learning the deployment side of the Add-ins/Global Templates. Once done though, it was a piece of cake. I’m actually fairly impressed. :)

Downloading the Add-ins

Heard enough? Sorry, just need to say a couple more things here…

  • The original XML code in these files was all produced by Microsoft. I have not modified it in any way at all.
  • The original userform has been modified by myself to allow copying of the imageMso name, but this was originally Zack Barresse’s idea.
  • The superior laziness of being able to click a button to have the imageMso copied to the clipboard is definitely a Zack thing as well. I wish I’d thought of how to be quite that lazy, but I didn’t. :(
  • The idea to extend this to Word & Powerpoint, I’ll lay claim to, though. ;)

And at long last… here’s the file! :)

Office 2007 Icons Gallery

Rant: Background apps that steal focus

I wasn’t planning on putting up more than one rant a month, but this just bugs me…

I’m an accountant. I know how to type. It’s month end. These three things are pretty important and related.

So here I am today banging in inventory numbers, one hand tracing down the list, and one hand flying over the number keypad as fast as I can go. Now, that’s pretty darn quick, (if I don’t say so myself,) and I’m also quite accurate, so I just don’t need to look at the screen until I “feel” a number go wrong. (Seriously, I do this so much it’s almost like breathing.)

After banging in a page of these things I look up, and there is Symantec’s Antivirus scanner in the forefront happily chugging along. It took focus of the screen after line 3 of my entry, so I’ve happily plugged about 90% of my work into an interface that just doesn’t care. Grr….

Why do applications like this pop up and take focus away from other apps? Do you honestly think I want to watch you scan every file? NO! Put an icon in the system tray and be done with it!

On a related note, I emailed one of our software vendor’s yesterday asking them to remove their splash screen as well. It takes a minute to load the program the first time through, and their splash screen stays in the fore front of all programs while it does. While you can type into another program if you reactivate it, you can’t see it for the splash screen. This is just ridiculous, IMHO. I pointed out that I spent a large amount of money on their program, knew what it was, used it daily, and didn’t need to be reminded of that fact every time I opened it. Not very power-user friendly, IMHO.

At any rate, enough ranting. I’ll try and post some technical content soon. :)