Archive for January, 2013

Since time immemorial, you’ve been able to save formatted and unformatted text for re-use in Word. Originally, this was called “AutoText”; in Office 2007 it was renamed “BuildingBlocks”.

These can only be saved in Templates. Originally, they were saved by default to Normal.dot; since 2007 the default storage is an independet file, “Built-in Building Blocks.dotx”. But you can choose any document of type template.

The user can choose an entry from a list and Word will insert it at the current selection. The Word APIs also provide access to this functionality.

But what’s the situation with the Word Open XML file format? Is there a simple way to insert AutoText/Building Blocks from a template “container” into a document? Read the rest of this entry »

Comments No Comments »

In my last post I showed how to change the target version of Word for a document using the Open XML SDK in order to ensure that “[Compatibility Mode]” does not appear in the document’s title bar. The code sample was in C#.

In this post I provide the code sample for VB.NET. Due to a bug in VB.NET Linq, it’s not possible to use the same “simple” approach as for C#. VB.NET Linq does not recognize the URI property as a property for the Compatibility Setting. The VB.NET equivalent of the C# approach (included near the end of the code sample, but commented out) causes an error. Read the rest of this entry »

Comments No Comments »

A relatively frequent request we see in the Open XML SDK forum is how to make the [Compatibility Mode] text in the Word title bar disappear.

By default, the Open XML SDK will create a document compatible with Word 2007. When opened in a later version of Office, [Compatibility Mode] appears in the document title bar. The question is, how to make the document a Word 2010 or Word 2013 document. Read the rest of this entry »

Comments 1 Comment »

UPDATE 20-JUL-2013: Microsoft has provided a “Roadmap” for the various technologies for developing with Office applications. In a nutshell, it states that all three current technologies will continue to be supported for the foreseeable future: http://blogs.msdn.com/b/vsto/archive/2013/06/18/roadmap-for-apps-for-office-vsto-and-vba.aspx

With the introduction of the new “Apps for Office” in Office 2013 a lot of people are asking about the future of Office programming. Is VBA going to be discarded? How about VSTO and the COM Add-in technology, generally? Will everyone have to learn Java script in order to do anything with Office? Read the rest of this entry »

Comments 1 Comment »

As more people migrate away from Word 2003 and 2007 to a newer version, more bugs are starting to come out of the woodwork. Again, this one was brought up in a forum.

When a developer writes code to use Word’s built-in Find functionality, it’s usually to do a “Replace all”, or to run a loop that stops after every “hit” until the entire search Range has been processed. It’s therefore common practice to pass wdFindStop to the Wrap property (or argument of the Execute method).

It’s only rarely that we see code using wdFindAsk, so perhaps it’s not surprising that the bug hadn’t been reported previously by earlier adapters of Word 2010…

In the problem scenario, Find should only run on the current selection, then ask the user whether it should continue to execute across the entire document. This is quite legitimate and imitates the user interface. What’s happening is that Find does not stop after checking the current selection, but continues to run for the entire document (does the same as wdFindContinue).

Interestingly enough, wdFindAsk does work correctly when the end of the document is reached, asking the user if the search should continue from the beginning of the document.

Following is some VBA code that works around the problem, so that the user is queried both at the end of the selection and at the end of the document. Read the rest of this entry »

Comments No Comments »