Getting Started / Limitations:
* SharePoint Metadata in Word 2003 is assigned more than Document Properties
* Only fields of type "Text" can be assigned (If you need to display the values of other text fields, you must add a text field to your type of content and use an EventHandler to copy the value to the desired the text field and the map as Doument this property to your Word template. A common scenario might be "version" or author of a document that are not text fields OOB)
* Properties OOB document updates Print only (This is a Word option that is set by default)
How:
* Link to your Word template for ContentType corresponding DocLib
* Add the following code, which updates the fields when the document is opened, such as Macro (Macro in the current document, not as module) for the Word template:
- Private Sub Document_New()
- ActiveDocument.Fields.Update()
- End Sub
- Private Sub Document_Open()
- ActiveDocument.Fields.Update()
- OStory As Object
- 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 the fields in all stories
- Next oStory
- For Each OTOC In ActiveDocument.TablesOfContents
- oToc.Update() 'update TOC
- OTOC Next
- Application.ScreenUpdating = True
- End Sub
- Private Sub Document_Close()
- ActiveDocument.Fields.Update()
- End Sub
- Document_Sync Private Sub (ByVal SyncEventType As Office.MsoSyncEventType)
- End Sub
This code updates all sections of the document, including header and footer, not only the content section.
Save the template and create your first document of this template.
No comments:
Post a Comment