Programmatically setting properties on a document created from atemplate

B

Brian Harvey

I am working on creating a template of document used by several of my colleagues and I. What I have so far is a document outline saved as a .DOTM (using Word 2007). I have coded a screen to popup and ask a few piecese of information. My issue is that when I post the template on our SharePoint site and someone (even myself) pulls down the file and then opens it, the form pops, I fill it out and click ok and a new document based on the template is created and called Document1, but none of the fields are populated. If I go back and look at the template I pulled down again I see where all of the values were written to the template instead of the document created from the template. How can I fix this?

Private Sub cmdCreate_Click()
Dim strTitle As String

strTitle = txtARNumber.Text & " - " & txtARTitle.Text
ActiveDocument.BuiltInDocumentProperties(wdPropertyTitle).Value = strTitle
ActiveDocument.Fields.Update
UpdateHeader

ActiveDocument.Bookmarks.Item("ARNUMBER").Range.Text = txtARNumber.Text
ActiveDocument.Bookmarks.Item("ARTITLE").Range.Text = txtARTitle.Text
ActiveDocument.Bookmarks.Item("ITSRNUMBER").Range.Text = txtITSRNumber.Text
ActiveDocument.Bookmarks.Item("AUTHOR").Range.Text = txtAuthor.Text
ActiveDocument.Bookmarks.Item("CREATEDATE").Range.Text = Format(Now, "MM/DD/YYYY")

Me.Hide


End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top