Posts Tagged “object model”

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 »

Currently, the list of underline types in the Office JS documentation is incomplete when compared with the list offered by IntelliSense (as seen in Script Lab). Read the rest of this entry »

Comments No Comments »

My previous post on getting started with Script Lab and the Office JS APIs for Word looked at some similarities between the COM and Word JS API object models, based on the Script Lab Basic API call sample. This time, I’ll highlight the core part of the sample code that differs from working with COM/VBA. Read the rest of this entry »

Comments No Comments »

Ran into an interesting question on Stack Overflow the other day. The problem description is short, so I’ll copy it here:

There is a word VBA method style("style").LinkToListTemplate ListTemplate:=Nothing which is used to set the style numbering to None. My problem is that I cannot find the same in C# word interop. The method exists but does not work with style.LinkToListTemplate(null).

Read the rest of this entry »

Comments No Comments »

If you’re curious about the Office JS API application object models and want to get acquainted you can do so without any investment other than time. All you need is a Microsoft account and Office 365 / Office 2016 installed on your machine (Windows or Mac) or access to Office Online. Then you can install Script Lab. Read the rest of this entry »

Comments No Comments »

…and the problem isn’t reproducible.

I was confronted with a request to trouble-shoot such a situation, not long ago. A large organization contacted me and this was the problem description. Read the rest of this entry »

Comments No Comments »

A poster in the Word for Developers forum has brought a new problem with the Documents collection to light this week. Unlike the one discussed in an earlier blog post, this behavior applies to all current versions of Word, including 2013.

Back when the Internet was comparatively new, Word didn’t know how to handle URLs as paths to files at all. The Open and Save methods of the Document(s) object couldn’t deal with anything that wasn’t a standard local or network path. At some point, this was rectified and Word can quite happily open and save documents to Internet, SharePoint and Skydrive sites.

What Word still can’t handle, however, is a URL as the index value to identify a Document object in the Documents collection. Code such as the following triggers the error 4160 “Bad file name”. Read the rest of this entry »

Comments No Comments »

[This is the follow-up to a previous post about mapping repeating content controls to a custom XML part.]
As a developer, you might want to be notified when the user adds a new set of mapped nodes to a repeating section, or deletes a set. If you look for events for Content Controls to help you with this you won’t find any.

Nor are there any events at the document or application level.

And you can’t re-purpose the entries placed in the context menu for adding or removing a repeating section item.
RepSec4

So, what can you do? Read the rest of this entry »

Comments No Comments »

Some significant improvements were made to Word’s content controls in Word 2013. You can find an overview here.

One interesting capability is a new kind of content control that brings back some of the functionality lost when XML nodes technology had to be pulled from Word due to the court decision in 2009. In the original release of Word 2007, xml nodes inserted into a table could be configured to repeat automatically when new table rows were inserted. While content controls in Word 2007 and 2010 can take over a lot of what could be done with xml nodes, this – and validation – were not possible “out of the box”.

A large portion of the article linked to above covers the new type of content control, in the section “Supporting repeating content”. You’ll also find a practical introduction, mainly targeting the “power user” on Greg Maxey’s site.

Something that doesn’t really jump out at you in any of the information I’ve found so far is how to

  1. Map a repeating section to a list of data already present in a Custom XML Part so that it all displays in the document
  2. Trap when the user adds or deletes a new data item (the repeating section must be mapped to a Custom XML Part in order for this to work)

Read the rest of this entry »

Comments 2 Comments »

I think many of us are still trying to come to terms with the fact that the only Help for Office 2013 is on-line. The official information can be found here:
http://technet.microsoft.com/en-us/library/cc178954.aspx
in the section AWS (Assistance and Worldwide Services).

The official line is that this is “better” all around. Help can now be searched on-line and translated. Of course, the fact that this was already the case for almost ten years isn’t mentioned…

Truth be told, the real reason is resources (financial). If Help has to be delivered with the product, then it has to be written before the product is released. This means lots of man-hours just prior to release, then down-time until the next product release. So, to a certain degree, the decision is understandable.

The other side of the coin, however, is that there’s no deadline that forces the documentation to actually be done and finished.

The result at the time of this writing, some months after the official release of Office 2013, is that the object model language reference (Help) hasn’t been reviewed for relevance to Office 2013, and new functionality isn’t fully incorporated. So you can spend literally hours trying to find information in the new, less friendly MSDN interface with the result that
you can’t find what you were looking for because it’s simply not there.

The “final straw” for me was a question about the Word object model in the Word for Developers forum the other day. So I’ve set up a new “page” on this blog to document un-documented behavior and information concerning Office. Everyone is welcome to contribute!

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

EDIT: There’s an update to this in a new blog entry. To summarize: this behavior is by design and there is a workaround for the problem.

A new bug was reported in the Word for Developers forum this week. I also received an email about the same behavior. Microsoft confirms the behavior but isn’t yet ready to call it a bug. I call it a bug.

To summarize: In all versions of Word through 2010, when you are monitoring the DocumentBeforeSave event the event only triggers if the user chooses to Save the document. If the user chooses not to save when the prompt appears, the event does not trigger.

In Word 2013 the event also triggers when the user chooses “Don’t save”.

Comments No Comments »

When you create a new document in Word, it automatically bases on a template. By default, this will be the built-in Normal.dotm, but it can be any *.dotx or *.dotm file. This document will maintain a link back to the template, enabling it to use Building Blocks, Ribbon customization and macros in the template.

Users and companies provide templates for specific, oft-occurring tasks. In order to make them easily discoverable, they should appear in the interface presented for creating a new document. With the exception of Word 2007, that had an “Office button” rather than a File menu, this interface is accessed via the command File/New.

Up until the introduction of the Backstage in Office 2010, this interface was the File New dialog box. In Office 2010 and 2013, it’s a Backstage view, but in Word 2010 you have to click the link “My templates” in order to access custom templates, which are still offered in the File New dialog box. In Word 2013, custom templates are listed in the Backstage view in the “Personal” list (below), but not necessarily all of them. Why this is, is the topic of this post. Read the rest of this entry »

Comments 9 Comments »

It’s been over a month since I last wrote an article. Obviously, I’ve been busy…

Among other things, we’ve signed a contract for a fourth edition of “Word Programmierung, Das Handbuch” with Microsoft Press, Germany. Word developer books don’t have it easy on the software book market and the German-speaking market is comparatively limited in scope. So we’re very proud that our work is still selling well enough after almost ten years to warrant a fourth edition. Read the rest of this entry »

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 »

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 »

Comments 2 Comments »

New month, new topic – for the moment, at least. Forums are such a wonderful source of topics to write about… Today’s comes from a question in the Office 2013 Preview for Developers forum on MSDN.

In Word 2010 the Backstage was introduced with the purpose of providing management functionality for Office documents. The Backstage provides a large, for the developer customizable surface to interact with the user. Another reason for this move was to provide the same “experience” for the users of all the Office applications when using basic file management functionality.

As always, when something is “harmonized”, individuality is lost. We’ve experienced that since the first attempts at giving the Office applications a unified interface and the trend continues. Read the rest of this entry »

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

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 »