Posts Tagged “workaround”

Since the release of Word 2013 we’ve been seeing sporadic complaints in the Word forum from developers that the selection highlighting disappears after their code executes. Only yesterday did someone post steps to reproduce the issue that worked consistently.

It turns out that this is, indeed, “unexpected behavior”. Apparently the screen redraw isn’t firing as it should.

There is a workaround, although it’s not ideal as it causes some screen flicker:

The Application.ScreenRefresh method will make the selection highlighting visible, again.

Changing the zoom factor should also work.

Comments 2 Comments »

In a previous post I wrote about a change in Word’s behavior: Even if the user chooses “Don’t save” when closing a Word document, the DocumentBeforeSave event triggers.

We’ve been thinking this is a bug, but it turns out that it’s not – it’s by design. Read the rest of this entry »

Comments 1 Comment »

The more people use Word 2013, the more changes and problems are bubbling to the surface. Again, this one was brought to the world’s attention in the Word for Developers forum.

“Reading mode” was introduced a few years ago to provide a more efficient way to read documents on-screen. By default, documents opened from an e-mail attachment will display in this view. As the view is optimized for reading, most editing commands are not available while in that mode. This lock-out also applies to the object model. When code tries to make modifications to the document that aren’t allowed while in reading mode, you see run-time error 4605: “This method or property is not available because this command is not available for reading”. Read the rest of this entry »

Comments 6 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 »

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 »

A fairly common question in the world of Word Development is how to merge multiple documents into one. (See for example this discussion in the MSDN Open XML SDK forum.) Read the rest of this entry »

Comments No Comments »

A person in the Word for Developers forum brought an important bug to our attention last week. When documents are opened/created then closed the Documents collection does not keep proper track. The index value is not reduced correctly (there are more documents in the collection than there should be) and some document names are missing while others are duplicated. (The thread with repro code sample can be found here.) Read the rest of this entry »

Comments 10 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 »

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 »