0
votes

I'm writing a Word 2010 VSTO application add-in. We're loading a dotx template file dynamically as follows:

word.AddIns.Add("C:\myTemplate.dotx", true);

The above works fine for one user but as another user calls the code we get a "File in Use" Word dialog with a prompt for the user on how they want to open the document.

How can we open the dotx file as read-only to avoid this dialog?

For background info, we're using BuildingBlocks from the dotx.

Thanks Si

1

1 Answers

0
votes

We can get the template as read-only and read the building blocks by simply doing the following:

Document document = word.Documents.Open("C:\myTemplate.dotx", false, true);
Template template = document.get_AttachedTemplate();

var blockCount = template.BuildingBlockEntries.Count;
var firstBlock = template.BuildingBlockEntries.Item(1);