Wednesday, April 11, 2012 7:46 PMI created content type for document library using visual studio. Currently I have manually added word document template to the document library content type which contains quick part properties from my content type. Now I want to do it programmatically. I mean, i want to add word document template to my project and add that word template to content type and deploy it as feature. Anyone has idea? Please try to explian step by step. Thanks.
- Edited by AshitaP Thursday, April 12, 2012 5:27 PM
Wednesday, April 11, 2012 9:10 PM
Doing this using Visual Studio is pretty easy, this guide will show you the exact steps:
Deploying documents with content types and associating content types with libraries (Part I)http://blogs.msdn.com/b/vssharepointtoolsblog/archive/2010/05/26/deploying-documents-with-content-types-and-associating-content-types-with-libraries-part-i.aspx
If youre in a sandboxed environment, then you will need to deploy the document file to a different place, but in a farm mode scenario this will work.
- Marked As Answer by AshitaP Thursday, April 12, 2012 12:52 PM
Monday, April 16, 2012 4:01 PM
I appriciate the help provided by Thomas. The idea is working to deploy word doc template in Layout folder. But I wanted to deploy it into _cts folder with content type.
Finally, I found the soltion for that.
Step 1: In your content type code, add following code after <FieldRefs></FieldRefs>.
<Folder TargetName="_cts/YourFeatureName/YourContentTypeName" /> <DocumentTemplate TargetName="YourTemnplate.docx" /> </ContentType> <Module Name="YourContentTypeName" Url="_cts/YourContentTypeName" RootWebOnly="TRUE" Path="YourContentTypeName" > <File Url="YourTemplate.docx" Type="Ghostable" /> </Module>
Right click on your content type in solution explorer, click add existing file and then browse to your word document template and add it to content type.
Add your Documet Template File(.docx) to 'C:/Program Files/Common Files/Microsoft Shared/Web Server Extensions/14/Template/Features/YourFeatureName/YourContentTypeName'.
Now deploy it and you are all set.
- Marked As Answer by AshitaP Monday, April 16, 2012 4:01 PM
Thursday, August 23, 2012 9:48 PM
I have successfully got my Content Type to include a custom Document Template. However, when I try to include the Content Type with a custom List Definition the Document Template is not included with the List. Any ideas?
<Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <!-- Parent ContentType: Document (0x0101) --> <ContentType ID="0x01010062188da313be476c8426c7595ced7355" Name="$Resources:HomeownershipDocument" Group="$Resources:ContentTypes" Inherits="TRUE" Description="$Resources:HomeownershipDocument_Description;" Hidden="FALSE" Version="0"> <FieldRefs> </FieldRefs> <Folder TargetName="_cts/Homeownership Document" /> <DocumentTemplate TargetName="template.dotx" /> </ContentType> <Module Name="Templates" Path="Homeownership Document" Url="_cts/Homeownership Document"> <File Url="template.dotx" Type="Ghostable" /> </Module> </Elements>
<MetaData> <ContentTypes> <ContentType ID="0x01010062188da313be476c8426c7595ced7355" Name="HomeownershipDocument"> <DocumentTemplate TargetName="template.dotx" /> <Folder TargetName="Forms/Homeownership Document"/> <FieldRefs> </FieldRefs> </ContentType> </ContentTypes> <Fields>...</Fields> <!-- removed for brevity --> <Views>...</Views> <!-- removed for brevity --> <Forms>...</Forms> <!-- removed for brevity --> </MetaData>