So i had to find a generic solution do display SharePoint Metadata in Word 2003 templates. I found different solutions to achieve this, but none of them solved all my Problems. The most common Problem ist the update of your Fields at the right time.
Basics / Limitations:
- SharePoint Metadata is mapped into Word 2003 over Document Properties
- Only Fields of Type "Text" can be mapped (If you need to display Values of other Fields than Type Text, you need to add a Textfield to your Content Type and use a Eventhandler to Copy the Value of your desired Field to the Textfield and map this as Doument Property to your Word Template. A common case could be "Version" or Author of a Document, which are OOB no Textfields)
- OOB Document Properties are updated on Print only (This is a Word Option which is set by Default)
- Bind your Word Template to corresponding ContentType of the DocLib
- Add the following Code, which updates the Fields when the Document opens, as Macro (Macro on the current Document, not as Module) to your Word Template:
Private Sub Document_New()
Private Sub Document_Open()
Dim oStory As Object
Dim oToc As Object
'exit if no document is open
If Documents.Count = 0 Then Exit Sub
Application.ScreenUpdating = False
For Each oStory In ActiveDocument.StoryRanges
oStory.Fields.Update 'update fields in all stories
For Each oToc In ActiveDocument.TablesOfContents
oToc.Update 'update TOC's
Application.ScreenUpdating = True
Private Sub Document_Close()
Private Sub Document_Sync(ByVal SyncEventType As Office.MsoSyncEventType)
This Code updates all Sections of the Document including Header and Footer, not just the Content Section.
Save your Template and create your first Document from this Template, enjoy the Interopability from SharePoint 2007 and Office 2003. ;-)
Any idea to make it two way? That is to say, change the document, and get the metadata updated?
Sorry, I haven't seen that with Office 2003. For such scenarios I would suggest use Office 2007.
How will this work when user is uploading a document instead of creating new from Sharepoint Doc Lib?
great, but there's a limitation on 256 signs, am I right? Any idea how to bypass this limitation to get more text in this field?