July 14, 2018
A few days ago I encountered a question on Stack Overflow about using tabs to align content in a Word document. The required result was something like this:

I started looking at the Word JS API documentation and realized there is nothing in that object model for inserting tabs or defining tab stops. Read the rest of this entry »
No Comments » |
Office JS API, OOXML, Web Add-ins, Word object model | Tagged: add-in, object model, office-js, OOXML, Web Add-ins |
Permalink
Posted by WordMeister
January 31, 2014
As more and more developers migrate to Visual Studio 2012 and/or Visual Studio 2013, we’re seeing requests in the Open XML SDK forum for a version of the Open XML Package Editor that works with these new versions of Visual Studio.
(The Open XML Package Editor lets you view the structures and XML content in an Office Open XML zip package and edit it, something the Open XML SDK Productivity Tool does not support.)
Unfortunately, at the time of this writing, Microsoft has not updated the tool – originally written for Visual Studio 2010 – nor released a new version. Luckily for all of us, a resourceful colleage of mine who attended my seminar in Lucerne – Dr. Eckehard Pfeifer – did some research that he said I might share :-) Read the rest of this entry »
2 Comments |
General, OOXML | Tagged: Open XML SDK |
Permalink
Posted by WordMeister
January 8, 2014
There was a discussion in the Open XML SDK forum today that I found interesting. Certain namespaces for Office 2010 weren’t being recognized with a reference to the Open XML SDK version 2.0, even though they should have been. The references were being picked up just fine with a reference to the newer Open XML SDK 2.5, however.
When I tested I had no problems using the namespaces. Luckily, I thought to include the version number of the Open XML SDK runtime in my reply. Turns out that Microsoft replaced the original download with a newer version without any public notification, either about the fact that it was being done or mention about problems with the older version. When the OP downloaded the newer version, the problem disappeared!
So if you need to use the older version of the Open XML SDK and are having problems with any namespaces that belong to DocumentFormat.OpenXml.Office2010.Word.DrawingShape
, try uninstalling, downloading a newer version and re-installing. You need a version that starts with v2.0.5###; the problem was ocurring in v2.0.4###.
No Comments » |
General, OOXML | Tagged: bug, Open XML SDK |
Permalink
Posted by WordMeister
July 21, 2013
There was a question the other day in the Open XML SDK forum about inserting Continuous section breaks. Inspecting a document.xml file, you’d think it would be as simple as adding a SectionType
child element to a SectionProperties
element associated with a paragraph’s properties, as can be seen in the following Word Open XML:
<w:p><w:pPr><w:sectPr w:rsidR=”0008038F” w:rsidSect=”00C26E80″>
<w:type w:val=”continuous”/>
<w:pgSz w:w=”11906″ w:h=”16838″/>
<w:pgMar w:gutter=”0″ w:footer=”708″ w:header=”708″ w:left=”1417″ w:bottom=”1134″ w:right=”1417″ w:top=”1417″/>
<w:cols w:space=”708″/><w:docGrid w:linePitch=”360″/>
</w:sectPr></w:pPr></w:p>
If only it were that simple! Read the rest of this entry »
No Comments » |
OOXML | Tagged: OOXML, Open XML SDK, section break |
Permalink
Posted by WordMeister
January 25, 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 »
No Comments » |
OOXML | Tagged: OOXML, Open XML SDK |
Permalink
Posted by WordMeister
January 23, 2013
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 »
1 Comment |
OOXML | Tagged: bug, Open XML SDK, workaround |
Permalink
Posted by WordMeister
January 18, 2013
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 »
2 Comments |
OOXML | Tagged: OOXML, Open XML SDK |
Permalink
Posted by WordMeister
January 10, 2013
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 »
1 Comment |
General, OOXML |
Permalink
Posted by WordMeister
December 31, 2012
There is apparently a bug in the Open XML SDK 2.0 when trying to work with a document that contains a Ribbon extension using the namespace for Office 2010 <customUI xmlns=”http://schemas.microsoft.com/office/2009/07/customui“>
If the document contains a customUI12 part, you get the error ArgumentOutOfRangeException when using WordProcessingDocument.Open.
The problem appears to be fixed in Open XML SDK 2.5, which requires the .NET Framework 4.0. Read the rest of this entry »
No Comments » |
OOXML | Tagged: bug, Open XML SDK |
Permalink
Posted by WordMeister
December 26, 2012
While trying to find the namespace for an Office 2013 Ribbon I checked the ECMA pages today and discovered that the 4th edition of the ECMA-376 standard has been released this month.
It can be downloaded in four parts at
http://www.ecma-international.org/publications/standards/Ecma-376.htm
Not yet updated are the special Office Implementation Extension standards for things like the Ribbon and Toolbars. Let’s hope, now that the ECMA-Standard is public, that these will soon follow!
No Comments » |
General, OOXML | Tagged: OOXML |
Permalink
Posted by WordMeister
October 6, 2012
Once again, a forum question has prompted a topic for my blog. This time, it comes from the discussions about developing for Office 2013.
For many years, a main focus of my work with Word has been related to importing and exporting data into and out of Word documents. The built-in functionality for this has always been “mail merge”. So I’ve worked with mail merge a lot. Unfortunately, it hasn’t really evolved since the early days of Word, around 1990. The only significant change occurred in Word 2003, when OLE DB became a supported connection method to the data source (and the default). Read the rest of this entry »
2 Comments |
OOXML, Word 2013 | Tagged: mail merge, object model, Office history, Open XML SDK, Word 2013 |
Permalink
Posted by WordMeister
September 21, 2012
In the Open XML forum the other day a person was concerned about mail merge main documents they were converting from Word 2003 to Word 2010. The users insert merge fields in these documents that serve as “targets” for writing data into the documents. The software company is updating its tool to use the Open XML file formats to insert the data.
They were encountering a problem when opening the documents in Word 2010 to save them to the new file format. Read the rest of this entry »
No Comments » |
OOXML, Word 2013 | Tagged: co-authoring, merge fields, OOXML, Skydrive, Word 2013 |
Permalink
Posted by WordMeister
September 18, 2012
As described in earlier posts, Word 2007 and Word 2010 don’t properly save number formats to number-type form fields. So I decided to try my hand at my first serious manipulation of Office Open XML files. As I felt more comfortable with old-fashioned XML coding, the tool presented in that post only leveraged the Open XML SDK for opening the file “package” and obtaining the required Part from the package.
Once it was clear that my approach did work, it was time to see if I could do the same using the full capabilities of the Open XML SDK. Read the rest of this entry »
2 Comments |
OOXML | Tagged: form fields, OOXML, Open XML SDK |
Permalink
Posted by WordMeister
September 11, 2012
I thought it would be really cool if I could post code that would modify Word 2007 and Word 2010 documents to fix the numbering format problem described in my last post without needing to use Word 2013. I was stymied for three days by the error message:
“The specified package is invalid. The main part is missing.”
It came up part of the time, but not all the time, for Word documents of all types when I tried to open them like this:
WordprocessingDocument doc = WordprocessingDocument.Open(openXMLFileName, true);
The error message is mentioned often in questions in various forums, but I could almost never find a resolution for it and the questions that were answered were not for my scenario. One piece of information did help me, though: the actual cause comes from the underlying System.IO.Packaging
namespace. The message indicates that System.IO.Packaging
doesn’t find valid parts and relationships.
Sure enough, when I checked for the number of Parts in a document I got 0 (zero). This was extremely puzzling and I lost a few hours sleep. The next morning a moderator in the Open XML SDK forum confirmed that he had no problems accessing the files. So the issue was certainly due to my machine’s configuration. What next?
I finally decided to test files from a different Windows folder as I was beginning to suspect a permissions problem. Sure enough, documents in “My documents” worked without a hitch. Using the Windows Share wizard, I granted “share” permissions to “everybody” for the folder with my test files – et voilà, problem solved!
2 Comments |
OOXML | Tagged: OOXML, Open XML SDK |
Permalink
Posted by WordMeister
September 10, 2012
One of the most frustrating things for Word power users and developers is the accumulation of “bugs” in the product. If a problem is not caught early in the beta stage, it’s often around to stay. When pressed, the product team will often say that changing “expected behavior” will break backwards compatibility. Another reason we hear is that available resources are being used to “improve the product” (add new things). So when someone discovers a bug has actually been fixed, it’s a reason to ring the bells!
A few days ago a colleague asked me to check whether there really is no work-around for a problem that cropped up when Word moved from the binary *.doc to the Open XML *.docx file format in Word 2007. When a file containing form fields is saved as a template in Word 2007 and in Word 2010 any Number Formatting applied to a textbox form field is lost.
Before confirming the issue, I decided to test it in Word 2013, even though I was pessimistic, given Microsoft’s track record. But lo and behold: The problem has been fixed! Templates saved in Word 2013 retain the number formatting. What’s more, when used in Word 2007 and Word 2010, the templates function as they should.
So not only is a bug fixed, but at the same time a work-around for the problem in Word 2007 and Word 2010 is now available.
Technical details:
The problem can be seen and even corrected in the Word Open XML file. Locate a form field by searching in document.xml for the element
(denotes a textbox form field). Below that look for the child element
. If there is no child element
then you’ve found a potential problem spot. Here’s a sample of correct Open XML for a form field with a number format:
<w:textInput>
<w:type w:val=”number” />
<w:format w:val=”#’##0.00″ />
</w:textInput>
No Comments » |
OOXML, Word 2013 | Tagged: bugfix, form fields, OOXML, Word 2013, workaround |
Permalink
Posted by WordMeister