Custom Ribbon example in Walkenbach's "Excel 2007 Power Programming with VBA"


Greg Lovern

I'm trying to do the custom ribbon example on pages 736 - 739 of John
Walkenbach's "Excel 2007 Power Programming with VBA".

I haven't been able to get the example files that should have been on
the cd (the cd just has a file that says it wasn't ready). So I'm
walking throught it manually. I'm getting the error "Excel cannot open
the file 'Excel 2007 Custom Ribbon Example.xlsm' because the file
format or file extension is not valid. Verify that the file has not
been corrupted and that the file extension matches the file format of
the file."

I've tried it with two new workbooks; same problem with both.

I do have "Show Add-In User Interface Errors" turned on.

Here's the VBA module text:

Sub CustomRibbonExample(control As IRibbonControl)
MsgBox "ok"
End Sub

Here's the customUI.xml:

<customUI xmlns="
<tab idMso="TabData">
<group id="Group1" label="Custom">
<button id="Button1"
label="Custom Ribbon Example"
imageMso="HappyFace" />

Here's what I added to the .rels:

<Relationship Type="
relationships/ui/extensibility" Target="/customUI/customUI.xml"
Id="12335" />

And here's the whole .rels:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Relationship Type="
relationships/ui/extensibility" Target="/customUI/customUI.xml"
Id="12335" />
<Relationships xmlns="
relationships"><Relationship Id="rId3" Type="http://
properties" Target="docProps/app.xml"/><Relationship Id="rId2"
metadata/core-properties" Target="docProps/core.xml"/><Relationship
Id="rId1" Type="
relationships/officeDocument" Target="xl/workbook.xml"/></

Any idea what's wrong?



Jim Rech

The error message says that the file extension does not match the type of
file. The XLSM extension indicates a file in the new Excel 2007 format that
contains a VB project. So something isn't right with the file. Either it
doesn't have a VB project or the file is not in the new format or it is
corrupted or ... who knows.

To see an example of this name mismatch, save an empty new Excel file as a
workbook (XLSX supplied automatically by Excel). Close it, rename it to
XLSM via Windows Explorer, and then try to open it.

If you really think it meets all the requirements I'd be happy to look at it
if you want to email it to me.

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question