Word Add-ins Part 3: Search for Text Strings in Documents and Add Comments (Harry Miller)

You can search the text in any open Microsoft Office Word document for specific strings if you put the code in an application-level add-in. When you find an instance of the string, you can perform some action on it. This video shows how to flag the string with a comment that contains text passed in… Read more

Word Add-ins Part 2: When Add-ins Collide (Harry Miller)

When you build an add-in project, it installs the add-in on your development computer. Even if you close that project and start another, or even close Visual Studio entirely, all add-ins you have built will still run when you start the Office application on that computer. If you’re not expecting the add-in to run, you… Read more

Word Add-ins Part 1: Clear the Ribbon Except for My Controls (Harry Miller)

You can easily customize the Ribbon to show only the controls you want to display. This video shows how to clear the Ribbon in Microsoft Office Word so it contains only a single button. The button inserts a graphic into the open Word document at the cursor location. Why? Well, really it’s just to demo… Read more

Create an Excel Shortcut Menu That Writes Selected Values to a Text File (Harry Miller)

It doesn’t take much code to add a command to a shortcut menu in Excel, but the menu objects have strange names so it’s not intuitive, to me at least. The trickiest part is just sorting out how it’s supposed to work, because it seems like it should be different from adding buttons to toolbars,… Read more

Activating a Custom Tab on the Ribbon When a Document Is Opened (Harry Miller)

A lot of people would like to do this. It makes sense that a developer would want to select the custom tab automatically, if the controls that are most useful for the current document are all on that tab. This video goes in-depth about this programming question. OK, not really. The video just says you… Read more

Automatic project conversion / migration (Harry Miller)

By default, Visual Studio automatically converts Office 2003 projects into Office 2007 projects when you open the project, if you have the 2007 Office system installed on your development computer. But you can change that default behavior. Resources Forum: Visual Studio 2008 converts its own Office 2003 project Upgrading and migrating Office solutions Project upgrade,… Read more

Removing Customization Code Before E-Mailing a Document (Harry Miller)

When you create a document-level customization for a document, all the copies of the document will be customized too. Even if you save a copy of the document with a different name, when the document is opened it’ll try to find and run the code. All the saved data will still be there, it’ll just… Read more

Assembly Could Not Be Found or Could Not Be Loaded (Harry Miller)

This video tells the story of someone who created an Excel 2003 workbook project in Visual Studio 2008.  No matter what configuration he tried on the client machine, he got this error when opening the workbook: The assembly could not be found or could not be loaded. Here’s the setup: Windows XP Professional PIAs for… Read more

Catching Save or SaveAs in Word 2007 (Harry Miller)

You can override Ribbon commands and run your own code for Save or Save As, or you can simply cancel attempts to save a document in the DocumentBeforeSave event handler. Code and resources: Forum post: Microsoft Word 2007 Disable Save As Temporarily Repurpose Commands on the Office Fluent Ribbon DocumentBeforeSave event Video duration: 51 seconds… Read more

WPF in Office Solutions (Harry Miller)

A few months ago, Andrew Whitechapel wrote an article and sample application that demonstrates combining the native capabilities of an Office client application with the UI capabilities of WPF. Behind the UI, the application is connected to remote data and services via WCF and uses the RAD features of LINQ to manipulate that data. Some… Read more