All posts by whitney

What Causes Error 1154 in WiX

Credit: www.joyofsetup.com

Recently, as I was working on one of our installers, I had a very strange issue crop up. This particular installer is fairly complicated, but also fairly stable.  It has many managed custom actions, and I was merely adding some functionality to it. I was testing the installer and ran into an 1154 error:

“There is a problem with this Windows Installer package. A DLL required for this install to complete could not be run.“

That’s fine. This happens. It’s pretty common, actually.

  • Check the names in the custom action declaration.  Do they match the DLL and method name, including case?
  • Are you trying to run a 64bit DLL using a 32bit installer?
  • Are you running MakeSfxCA.exe correctly with the most recent version of the DLL and installer?
  • Does the method you’re trying to call have the correct signature?

[CustomAction]Public static ActionResult MyCustomAction(Session session){….}

In this case, my problem action was, let’s say, HereIsMyCA. I checked through all of the above items several times. Most confusing was that other custom actions from the same DLL worked just fine. One might say I was getting a bit frustrated.  Eventually, I changed the name of the action and method – ThisIsAwfulPleaseWork.

…and it did.

After some experimentation I discovered that the problem lay in the capitalization of the C# method.  HereIsMyCA was breaking, but HereIsMyCa was fine. Most other methods with similar capitalization (several capitals in a row) worked fine. I’ve had one other method break. There is no rhyme or reason to it, but I hope that I save someone some hours with my discovery.

Agile Development: 5 Lessons Learned

Working in software development can be challenging and tricky without the right plan in place, especially without a plan that caters to your employees’ work styles. Here at SoftArtisans our development team follows the agile dogma and we’ve discovered several lessons along the way. Wondering if agile development is right for your team? See below for 5 things to keep in mind when implementing this work style.

1. You absolutely need backup from higher-ups.

Too often I have seen or heard of departments that were “going agile,” but management was not behind them. No matter how enthusiastic about it the developers were, their plans were ruined every time management expected something to be “like it used to.” Managers who don’t give things time to adjust create developers who don’t give things time to adjust, and then everything is doomed to fail.

2. Retros are vital.

One important thing about agile is that you can change things quickly when you need to. This applies to the direction the software is taking, but it also applies to the processes and mindsets of team members. This is what retrospectives are for. A good team will be able to be honest about what’s working and what isn’t and subsequently make changes for future sprints.
This whole process is much easier when…

3. Retros don’t include higher-ups.

Management usually wants to know what’s going on, and that’s great, but retros are not the place for it. Continue reading Agile Development: 5 Lessons Learned

Creating Dynamic Menus in VBA Add-Ins

With the new release of OfficeWriter 8.1’s designer ribbon, I’ve been working more with the ribbon interface. This is a follow up post to one written previously on updating an old Office Add-In to use the new ribbon interface. In this post we’ll explore how to create dynamic menus in VBA Add-Ins.

Once you have the ribbon for a VBA Add-In, there are a number of things you can add to make the UI more useful.  One of the more versatile elements available is the dynamic menu.  This menu lets you change it during runtime!  Unfortunately, working with it in VBA is a little strange.

First add the base xml to the ribbon xml like you would for any UI element.


<group label=”Ribbon Group” id=”group1”>

<dynamicMenu label=”Dynamic Menu” id=”menu1″
imageMso=”TableInsert” getContent=”ReloadMenu”/>
</group>

The important attribute here is “getContent”.  This is a callback to a method in the VBA which will create the items for the menu.  The method will literally create xml for a menu from scratch and return it.  Anything that can normally be in a menu can be added this way – including buttons, submenus, and separators.  The sample code below creates a button and a submenu with another button inside it. Continue reading Creating Dynamic Menus in VBA Add-Ins

Adding Ribbons to VBA Add Ins

It’s fairly easy to update an old Office Add In to use the new Ribbon user interface.

There are two major steps to the process: creating an XML file to hold the ribbon information, and updating the macros to use IRibbonControls.  These directions will focus on Excel 2010, but the process will work for any Office 2007 or 2010 application with only minor changes.

Creating the Ribbon XML

The easiest way to get started is to use the Visual Studio tools for Office projects.  This will allow you to create the basic toolbar using drag and drop style tools.  In Visual Studio, create a new project and select Visual C# -> Office -> 2007 -> Excel 2007.  Right click in the project and select Add -> Office -> Ribbon(Visual Designer).  Right click on the created file and open the Designer.  Drag and drop and rename to your heart’s content.  When you’re done, right click on Ribbon and click “Export Ribbon to XML.”  Now you have the XML file that you will be using in future steps.

In order for the buttons on the ribbon to actually do anything, they need to have callbacks associated with them.  They will need to be added manually to your XML file.  All items have the option to set whether they are visible or enabled (using getVisible and getEnabled attributes).  Buttons have an onAction attribute, which is called when the button is pressed.  All of these are just the names of the macro that you want to call.

Example XML

<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
    <ribbon>
         <tabs>
               <tab id="Tab1" label=”TabName”>
                   <group id=”Group1” label=”GroupName”>
                       <button id=”button” label”ExampleButton” imageMso=”PercentStyle” 
                         onAction=”ButtonAction”/>
                       <menu id=”Menu1” label=”MenuName” size=”large”>
                           <checkBox id=”Checkbox1” label=”CheckboxName” 
                            onAction=”ToggleCheckbox” getPressed=”CheckCheckbox”/>
                       </menu>
                   </group>
                </tab>
          </tabs>
     </ribbon>
</customUI>
 

Creating the Add In File

Create a new workbook in Excel 2010.  Save it as an Excel Add In (.xlam).

Navigate to the new file in Explorer.  Rename the file to be a .zip file.  Modern office files are generally just zip files filled with xml files.  Extract the zip file so we can make some changes to it.

  • First, open _rels/.rels and add

<Relationship Id=”customUIRelID” Type=”http://schemas.microsoft.com/office/2006/relationships/ui/extensibility” Target=”customUI/customUI.xml”/>

beneath the other Relationships in the file.

  •   Next, create a folder in the top level of the zip file called customUI.  Copy your XML file into that folder and rename it customUI.xml.  Turn the zip file back into an .xlam (or whatever the original suffix was).  If you open the file, you should have a new ribbon on your tool bar.  It may throw errors if some of the callback macros don’t exist yet, but that is fine.

 

Hooking everything up

We’ll need to create or adjust the macros used in the XML file.  If you’re updating an existing add in, many of those macros probably already exist.  They won’t work out of the box, though.  All onAction macros require an IRibbonControl to be passed to it:

Sub ExampleMacro(control As IRibbonControl)

Other macros (such as getVisible or getEnabled) also need a return value:

Sub ExampleGetVisible(control As IRibbonControl, ByRef visible)

     visible = false

End Sub

These can all go in a module in the add in file.

 

At this point you should have a working add in with a ribbon interface.  The Microsoft website also has some good information on this process.