Neal said:
Does anyone know how to create a macro that would insert a bookmark
from another document that may not be active to an active document?
Would love to get an idea of the code.
Use an INCLUDETEXT field, and place the name of the bookmark after the name
of the file -- look of the field's syntax in the Word Help.
To do this in a macro, use the ActiveDocument.Fields.Add method like this
(notice that the file name must be in quotes if it contains spaces, and all
backslashes must be doubled):
Sub demo()
Dim Fname As String, BKname As String
Fname = "C:\somepath\source.doc"
Fname = Chr(34) & Replace(Fname, "\", "\\") & Chr(34)
BKname = "somebookmark"
With ActiveDocument.Fields
.Add Range:=Selection.Range, _
Type:=wdFieldIncludeText, _
Text:=Fname & " " & BKname, _
PreserveFormatting:=True
.Update
End With
End Sub
--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.