Posts Tagged “OOXML”

Once again, a question on Stack Overflow offered an intriguing problem that kept my brain busy for quite a while. When generating a table in a Word document cells containing no content would not retain the custom font size being assigned to each cell. Read the rest of this entry »

Comments No Comments »

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 »

Comments No Comments »

The previous post discussed how to find out what Word Open XML is required in order to insert a particular type of content. This article will consider a practical example and demonstrate how the Word Open XML can be stored in a resource file, then loaded and modified by JavaScript code before being inserted into the Word document. Read the rest of this entry »

Comments No Comments »

In both the posts about Coercion types in Word Web Add-ins and reading built-in document properties a key point is using the Word Open XML file format in order to achieve something not available in the APIs. This approach works only in Word and it can be used for almost anything. Even the newer, extended APIs that will be released for Office 2016 won’t (initially) provide functionality for everything that can be contained in a Word document. So working with the Word Open XML file format is a useful tool for the JavaScript as well as the VBA and .NET developer. Read the rest of this entry »

Comments No Comments »

Long-time Word users, especially those who work on professional documentation in multilingual environments, know that you have to be very careful that the language default in Word matches the default language setting in Windows. If it doesn’t, the Windows language will override the Word language as direct formatting in the document. Documents created in such an environment are difficult to get under control – it’s almost impossible to clean out the imposed Windows language without delving into the Open XML file format. Read the rest of this entry »

Comments No Comments »

In my last post I described how to achieve a continuous section break in Word Open XML. In this post, I go into how to force the continuous section break in the middle of a paragraph. Read the rest of this entry »

Comments 4 Comments »

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 »

Comments No Comments »

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 »

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 »

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!

Comments No Comments »

In the initial release of Word 2013 the new Comment extensions, contained in the commentsEx.xml part, are not written to the XML returned to the object model property Range.WordOpenXML. Read the rest of this entry »

Comments No Comments »

Now that we’ve looked at Comments in the Word 2013 user interface and object model, it’s time to consider how this has been implemented in WordOpenXML and the Open XML SDK. Read the rest of this entry »

Comments No Comments »

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 »

Comments No Comments »

There was an interesting question in the forums the other day that piqued my interest. How to create a chart in a WordOpenXML document that will function in Word 2000-2003 (using the converter in the Compatibiltiy Pack), in Word 2007 and in Word 2010. We actually figure it out in less than 24 hours! (That was a day the lightbulb did come on.) Read the rest of this entry »

Comments No Comments »

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 »

Comments No Comments »

No question: I’m object model-oriented. It didn’t take me long to recognize the advantages of object-oriented programming over Word Perfect keyboard macros and the user action emulation of WordBasic when VBA was introduced in the mid-90s! Read the rest of this entry »

Comments No Comments »

Having overcome the obstacle mentioned in my last post, I continued work on a small tool to manage the number formatting of number form fields in Word documents. While becoming acquainted with the principles of Open XML I’ve always felt there are too few samples demonstrating how to work with the various Office applications. So I plan to share some of my code in this blog. Read the rest of this entry »

Comments No Comments »

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!

Comments No Comments »

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>

Comments No Comments »