Archive for September, 2012

Changes in the Word Open XML for comment’s functionality in Word 2013 were presented in my last post. This time, we’ll look at how these changes affect working with Comments using the Open XML SDK. 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 my last post I presented some of the new Comment functionality in the Word UI. The new functionality for Comments is also reflected in Word’s object model. Read the rest of this entry »

Comments 3 Comments »

Creating and Editing Comments

When you give the command to insert a new Comment in Word 2013 a small pane appears near the current selection. It gives the name of the person entering the Comment and how long ago the Comment was generated. This information travels with the Comment. You just start typing.

The Comment pane can be dragged any where on the screen. It can also be resized by dragging any side or corner.

 When you’re finished, click the X at the top right corner of the pane or click outside it on the document surface. Read the rest of this entry »

Comments 6 Comments »

The Word team has once again invested quite a bit of thought and effort in good old “Track Changes”. A couple of versions back, we got:

  • the Revisions Balloons – the area that appears in the margin where track changes and comments are listed in little boxes with lines back to the text
  • and the Revisions task pane that can be positioned vertically on the left or horizontally across the bottom of the Word window – lists all changes in the various sections of the document.

One pain point with the balloons is that, if there are lots of comments and changes, things appear very “busy” and it’s difficult to sort out what entry in the margin refers to which range of text. It’s also not easy to follow a discussion being carried on in the comments as they may well not be listed in the order they were created.

So an effort has been made to simplify the display of revisions, on the one hand, and allow a discussion using comments, on the other. The comments part is easy enough to understand; the changes in how revisions can be displayed takes some hands-on experimenting and getting used to.

This is too much material to cover in a single blog post, so I’m going to break the discussion down into at least four entries. The first will look at Comments in the UI, the second at the changes in the object model related to Comments.

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 »

As I was gearing up to present a series of posts on programmatically incorporating Excel charts in Word, I realized that including multiple programming language versions in a blog post just isn’t the thing to do. My blog posts tend to be long enough as it is :-)

So I’ve started a new section of “pages” that you can access through the menu point “Equivalents” at the top of the blog. The idea is to enable people who understand either VB or C# to be able to follow code examples in the other language and be able to use the principles in their own code.

There’s potentially a lot of material to cover under the topic “Equivalents”, so I’ll be adding to it as I go along. If you have any particular pain point you’ve encountered while trying to work with “unreadable” code samples, leave a comment on the Equivalents page and I’ll try to include that topic… soon :-)

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 »

I remember the days when we used to phone for pizza to be delivered. It was a big deal; a special event. Couldn’t happen often enough. 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:type w:val=”number” />
  <w:format w:val=”#’##0.00″ />

Comments No Comments »

The Office applications are powerful tools created for a specific purpose, such as word processing or performing a large number of complex calculations. Even so, people expect them to be able to do “everything”. Since Microsoft wants us to buy Office and not use other word processing, spreadsheet, presentation or e-mail software, it has historically tried to meet as many expectations as possible (not always with great success).

As a result, the user interfaces and the object models tend to be large and complex, especially Word’s.

Even though Office is sold as a “suite”, all the core applications originated separately, most during the early 1990s. Internally the applications follow different philosophies, as best met the needs of the users when the feature was designed. This is also reflected in the programming interfaces (“object models” or “APIs”, depending on what programming background you come from). Word, Excel and PowerPoint tend to do the same thing differently, which can be confusing for developers coming from outside Office. In more recent versions, Microsoft has tried to provide common interfaces for things such as opening, saving and printing documents. As a result some applications have lost functionality while others have gained – the changes causing confusion for end-users and experienced Office developers.

What’s more, the way these object models are constructed bases to a large extent on how the user works with the Office application. For a developer with no end-user background, the logic behind many parts of the object models is baffling.

Given all these factors, finding information to achieve a goal or solve a problem can be challenging.  It’s important to know where to go for information and to ask questions – one-stop shopping isn’t an option.

Having experienced “the pain”, I decided to add a Link page to this blog site with links to the forums and web sites I consult most frequently when developing and assisting people on the MSDN forums. May it help you accomplish your goals more quickly :-)

Cindy Meister Office Developer MVP

Comments No Comments »

In my last blog post I described the new functionality in the Word 2013 UI for collapsing and expanding Headings and Outline levels. Today, I’ll cover the corresponding additions to the Word object model. Read the rest of this entry »

Comments No Comments »

Since the advent of dynamic web pages, users have been asking for a way to collapse and expand content in Word documents. The Word team has finally been able to implement this in Word 2013. When the user hovers the mouse pointer over a paragraph formatted with an outline level a triangle appears next to the paragraph:

Uncollapsed state

Uncollapsed state

Read the rest of this entry »

Comments No Comments »

Word has a long and colourful history. I’ve been working with it for over twenty years, and have the grey hairs to prove it :-)! Each new version brings change. Depending on your point of view, some good, some less so. With a few notable exceptions, those changes remain with us for many versions to come. One of the first things the seasoned user looks for is “What’s new” information.

I’m no exception to that rule. While exploring Word 2013 I’m encountering differences and trying to determine how they’ll affect my life, both as an end-user and as a developer. With so many years’ information stored in my brain, spanning ten versions of the application, I’m finding it increasingly difficult to remember “what belongs where”. So I started recording my findings.

Soon it occurred to me that others might be interested in this information. Therefore, I’m venturing on my first experience in blogging, rather than maintaining a website.

As time goes on, the content of this blog may well branch out and cover topics of interest I encounter in my work as forum moderator on MSDN. If you have any questions about developing with Word, please ask them on MSDN, not in comments on this blog. You’ll find me – and other helpful souls – in the VSTO, the Word for Developers, the General Office Development and the Open XML SDK forums.

Enjoy working with Word and the other Office applications!

— Cindy Meister, Office Developer MVP

Comments 2 Comments »