Swapping the the Word template in a VSTO project

We have recently swapped the Word template we use to make sure all our proposals and other documents are consistent. The changes are all cosmetic, fonts, footers etc. to match our new website; it still makes use of the same VSTO automation to do much of the work. The problem was I needed to swap the .DOTX file within the VSTO Word Add-in project, we had not been editing the old DOTX template in the project, but had created a new one based on a copy outside of Visual Studio.

To swap in the new .DOTX file for the VSTO project I had to…

  • Copy the new TEMPLATE2014.DOTX file to project folder
  • Opened the VSTO Word add-in .CSPROJ file on a text editor and replaced all the occurrences of the old template name with the new e.g. TEMPLATE.DOTX for TEMPLATE2014.DOTX
  • Reload the project in Visual Studio 2013, should be no errors and the new template is listed in place of the old
  • However, when I tried to compile the project I got a DocumentAlreadyCustomizedException. I did not know, but the template in the VSTO project needs to a copy with no association with any VSTO automation. The automation links are applied during the build process, makes sense when you think about it. As we had edited a copy of our old template, outside of Visual Studio, our copy already had the old automation links embedded. These needed to be removed, the fix was to
    • Open the .DOTX file in Word
    • On the File menu > Info > Right click on Properties (top right) to get the advanced list of properties


    • Delete the _AssemblyName and _AssemblyLocation custom properties
    • Save the template
    • Open the VSTO project in Visual Studio and the you should be able to build the project
  • The only other thing I had to do was make sure my VSTO project was the start-up project for the solution. Once this was done I could F5/Debug the template VSTO combination

Setting SkyDrive as a trusted location in Office 2013

We use a VSTO based Word template to make sure all our documents have the same styling and are suitably reformatted for shipping to clients e.g revision comments removed, contents pages up to date etc. Normally we will create a new document using this template from our SharePoint server and all is OK. However sometimes you are on the road when you started a document so you just create it locally using a locally installed copy of the template. In the past this has not caused me problems. I have my local ‘My documents’ set in Word as a trusted location and it just works fine.

However, of late due to some SSD problems, I have taken to using the SkyDrive desktop application. So I now save to C:\Users\[username]\SkyDrive and this syncs up to my SkyDrive space whenever it gets a chance. It has certainly saved me a few times already (see older posts my my SSD failure adventures)

However, the problem is that I can create a new document OK, VSTO runs, and save it to my local SkyDrive folder, but then I come back to open it for editing I get the error


The problem is my SkyDrive folder is not in my trusted locations list (Word > options > trust center > trust center settings (button lower right) > Trust locations)


So I tried adding C:\Users\[username]\SkyDrive – it did not work.

I then noticed that when I load or save from SkyDrive dialogs say it is coping to ‘https://d.docs.live.net/[an unique id]’. So I entered https://d.docs.live.net (and its sub folders) as a trusted location and it worked.

Now I don’t really want to trust the whole of SkyDrive, so needed to find my SkyDrive ID. Now I am sure there is a easy way to do this but I don’t know it.

The solution I used was to

  1. Go to the browser version of SkyDrive.
  2. Pick a file
  3. Use the menu option ‘Embed’ to generate the HTML to embed the file
  4. From this URL extracted the CID
  5. Added this to the base URL so you get https://d.docs.live.net/12345678/
  6. Add this new URL to the trusted locations (with sub folders) and my VSTO application works

Simple wasn’t it.

Outlook 2010 crashing after in place upgrade

I downloaded and installed the Office 2010 technical preview today. All seemed to go OK (after I realised  I could only do an in place upgrade from 32bit Office 2007 –> 32bit Office 2010), once the upgrade was done I could load Word and using our VSTO based document templates all seemed to work fine. However when I tried Outlook I got a problem.

On the first loading it took a while, telling me it was doing something to  40K+ items, presumably checking the local OST file, but then seemed to load OK. However after about 30 seconds it crashed, and continued to do this every time I rebooted Outlook even when I was tried safe mode, add-ins switched off and/or offline working. It all had no effect. Checking the event log I saw I had the error:

Faulting application name: OUTLOOK.EXE, version: 14.0.4006.1110, time stamp: 0x4a468538
Faulting module name: mlang.dll, version: 6.1.7100.0, time stamp: 0x49eea59f
Exception code: 0xc0000005
Fault offset: 0x00016aef
Faulting process id: 0x1060
Faulting application start time: 0x01ca06e3140fb30d
Faulting application path: C:\Program Files (x86)\Microsoft Office\Office14\OUTLOOK.EXE
Faulting module path: C:\Windows\system32\mlang.dll
Report Id: 5af5a171-72d6-11de-97df-001636a51764

I noticed that the in place upgrade had not removed Office 2007, so I did this via the control panel. After this Outlook loaded and was stable other than the fact the view panel would not load (was grey’d out on the menu), so stable but useless

I then tried a removing Office 2010 (there is no repair option) and reinstalling again using the same 32bit media. This time it knew it was not doing an upgrade but a new install. Once this completed I loaded Outlook and it worked fine including picking up my existing OST file (from a non default location, I keep it on a bitlocker partition) and also still had my CRM 4.0 add-in configured and working.

So it seems the upgrade can get  bit confused

Missing .NET framework installing a VSTO application

I have been getting the error “The required version of the .NET Framework is not installed on this computer.” (event id 4096 in Event log) when trying to install a VSTO application from both a ClickOnce deployment and a local copy. This is interesting as the .NET framework is installed (on my 64bit Windows 7 PC) and the VSTO application was developed on the self same machine (and works in Visual Studio 2008).

The fix, it turned out, was to uninstall Microsoft Visual Studio Tools for the Microsoft Office system (version 3.0 Runtime) (x86) and then reinstall it, once this was done the install worked fine.

Update 17th  Feb 09 A good list of what should be installed can be found at http://blogs.msdn.com/vsto/archive/2008/02/19/deploying-prerequisites-for-your-visual-studio-tools-for-office-solution.aspx. However here does seem to be an install issue over order and leaving incorrect development resource so a look at the diagnostic tools in http://www.microsoft.com/downloads/details.aspx?familyid=46b6bf86-e35d-4870-b214-4d7b72b02bf9&displaylang=en would not go amis. This should be an easy process when using VS2008SP1, but it does seem problematic.


Why doesn’t my ActionsPane appear when I create a new document form a VSTO enabled template?

When you are using a VSTO enabled Word Template inside a SharePoint custom content type you have to be careful which actual .DOTX file you use within the SharePoint custom content type.

  • DO NOT – use the .DOTX from your VSTO Visual Studio project directory
  • DO USE – the .DOTX from the the project’s ClickOnce publish location.

The key point here is that until you have published the VSTO project via ClickOnce the .DOTX template does not know where to find the deployment of the associated assemblies. The copy in the project directory never actually knows this location as it is just a source file not a deliverable.