Copy Text from Bookmark in SourceDoc to use as Document Variable in NewDoc
Hi,<br><br>I would like to have a Source Document set up with various bookmarks with text inside the bookmarks. I would then like to have different Templates with DocVariable fields throughout. When I create a new document from the template, I would like to run a macro that will copy the text from a particular bookmark in the SourceDoc and set it as the value for a particular DocVariable in the NewDoc.<br><br>This is what I have come up with, but I cannot get it to work for me, any help would be much appreciated.
Code:
Private Sub Document_New()
Dim oSourceDoc As Document
Dim oRng As Range
Set oSourceDoc = Documents.Open("SourceDoc")
oRng.Text = oSourceDoc.Bookmarks("bookmark").Range.Text
Set oVars = ActiveDocument.Variables
oVars("doc_variable").Value = oRng.text
Set oVars = Nothing
End Sub