Reputation: 3035
First of all I created a few test columns...
Secondly I created a new content type (derived from Document).
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ContentType ID="0x0101000F16F9EDC2D547C48480B02B918168DD" Name="MyDocContentType1" Group="Custom Content Types" Description="My Document Content Type 1" Inherits="TRUE" Version="0">
<FieldRefs>
<FieldRef ID="{d17ecdc8-991a-4efc-a758-bbb522dd2f62}" DisplayName="My Test Column 1" Required="FALSE" Name="MyTestColumn1" />
<FieldRef ID="{8e9ef300-b566-4939-8b3c-760e13afb6d5}" DisplayName="My Test Column 2" Required="FALSE" Name="MyTestColumn2" />
</FieldRefs>
<DocumentTemplate TargetName="~site/_cts/MyDocContentType1/MyDocumentTemplate1.dotx" />
</ContentType>
</Elements>
Next I created a module deploying my word 2013 template file (.dotx) to /_cts//MyCustomTemplate1.dotx
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="DocumentTemplates" RootWebOnly="TRUE" Url="_cts/MyDocContentType1">
<File Path="DocumentTemplates\MyDocumentTemplate1.dotx" Url="MyDocumentTemplate1.dotx" Type="Ghostable" />
</Module>
</Elements>
Adding the content type to a library enables the document template...
E.g. when I create a new item of "MyDocContentType1" it opens up Word 2013.
However the document template is not correctly bound to the server - the document information panel doesn't appear and I cannot add any quick parts refering to sharepoint content type columns.
It does work when I assign the document template via the SharePoint Web UI.
Any ideas?
Edit: The word template (.dotx) is already aware of the SharePoint columns. In a previous step I assigned the DocumentTemplate manually (to design the word template). Now that the .dotx template is feature complete I want to deploy it as part of a SharePoint solution (for example to a newly created site collection).
Edit: Of course it works using a programmatic approach assigning the DocumentTemplate property via feature event receiver. That's not the solution I am looking for. Declarative only.
To me it looks like a bug. If I go to the content type, edit/update the document template (updating - not uploading a new one!) and create a new document from that content type it starts to work... ?!
Upvotes: 1
Views: 2010
Reputation: 1328
I am going to assume that you created your *.dotx file directly in word and added it to Visual Studio.
The reason why it doesn't work is that the dotx file needs to have references to the SharePoint fields encoded in the Word file itself.
I would suggest to:
Upvotes: 1