Sorry, I missed that the last time. The way you wrote the statement,
the word PathRel is a literal, a part of the string, when what you
want is the variable name. The statement that inserts the field should
be
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _
Text:="INCLUDETEXT " & PathRel & "[Mybookmark] "
The & symbols (ampersands) are connectors to put together the pieces
of the string. The first piece is the word INCLUDETEXT and its space;
the second piece is the variable PathRel, which is replaced by the
value you previously assigned to it; and the third piece is the name
of the bookmark.
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ:
http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
On Mon, 3 Apr 2006 14:26:02 -0700, RRodrigues
wrote:
I've already tried that, but it doesn't worked.
I've run the macro with the path directly in the instructiont:
"INCLUDETEXT "Z:\\Word\\2006\\Reports\\'Filename.doc' " [Mybookmark] "
and it worked fine.
But when I replace the path with the assigned value PathRel, it returns
"Error! Not a Valid Filename".
Can you tell me what I'm doing wrong, please?
"Jay Freedman" wrote:
There are two things you need to fix:
- When you assign the value to PathRel, you need a backslash to separate the
path from the file name.
- For use in an IncludeText field, each backslash in the name must be
doubled.
So the line you need is
PathRel = "Z:\\Word\\2006\\Reports\\" & NameRep
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
RRodrigues wrote:
One more question...
How can I introduce a defined path in the instruction IncludeText,
with a VBA code?
I've made this code, but it doesn't work:
Dim Message, Title, MyValue
Message = "What's report number?" ' Set prompt.
Title = "Reports" ' Set title.
MyValue = InputBox(Message, Title)
NameRep = MyValue & ".doc"
PathRel = "Z:\Word\2006\Reports" & NameRep
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty,
Text:= _ "INCLUDETEXT PathRel [Mybookmark] " _
Can you help me with this, please?
"RRodrigues" wrote:
Thanks Jay!
That worked!
"Jay Freedman" wrote:
If you want document A to repeat the contents of a bookmark that's
in document B, then the field you want is an IncludeText field
containing the file path\name of document B and the bookmark name.
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
On Sun, 2 Apr 2006 03:45:02 -0700, RRodrigues
wrote:
Thanks Jezebel.
However, that creates an Hyperlink.
What I need is to create a Ref to a bookmark which is in another
document.
"Jezebel" wrote:
Use the Bookmarks button on the Insert Hyperlinks dialog
"RRodrigues" wrote in
message ...
How can I creat a cross reference to a bookmark from another
document?