InsertFile Path

D

Dave

I am trying to include another file into a currently open Word
Document using Selection.InsertFile FileName:="Intro.doc" in Word
2003.

Word looks in its current folder for the file. I need for Word to look
in the folder of the currently open file.

I tried "ChDir ActiveDocument.Path" but get a "Path Not Found" error.

thanks,

dave
 
J

Jay Freedman

Dave said:
I am trying to include another file into a currently open Word
Document using Selection.InsertFile FileName:="Intro.doc" in Word
2003.

Word looks in its current folder for the file. I need for Word to look
in the folder of the currently open file.

I tried "ChDir ActiveDocument.Path" but get a "Path Not Found" error.

thanks,

dave

Make the FileName parameter include the entire path of the file to insert.
Be careful to include the backslash before the filename, because the
ActiveDocument.Path doesn't end with one.

Selection.InsertFile FileName:=ActiveDocument.Path & "\Intro.doc"

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
D

Dave

Make the FileName parameter include the entire path of the file to insert.
Be careful to include the backslash before the filename, because the
ActiveDocument.Path doesn't end with one.

Selection.InsertFile FileName:=ActiveDocument.Path & "\Intro.doc"

--
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.

I get a "File Not Found" error with this. "ActiveDocument.Path" seems
to come up as a blank.

For some reason, the following will work:

Set DocA = ActiveDocument
Selection.InsertFile FileName:=DocA.Path & "\Intro.doc"

Not as elegant, though.

thanks,

dave
 
J

Jay Freedman

I get a "File Not Found" error with this. "ActiveDocument.Path" seems
to come up as a blank.

For some reason, the following will work:

Set DocA = ActiveDocument
Selection.InsertFile FileName:=DocA.Path & "\Intro.doc"

Not as elegant, though.

thanks,

dave

That doesn't make sense to me. The only time ActiveDocument.Path should be empty
is if the active document has never been saved (that is, it's still "Document1"
etc.). In that case, it wouldn't make any difference to assign it to a variable.

And yes, I did try that code before I posted it, and it works for me.
 
D

Dave

That doesn't make sense to me. The only time ActiveDocument.Path should beempty
is if the active document has never been saved (that is, it's still "Document1"
etc.). In that case, it wouldn't make any difference to assign it to a variable.

And yes, I did try that code before I posted it, and it works for me.

--
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.- Hide quoted text -

- Show quoted text -
Very odd! Once I figured out I was getting blanks, I tried it a couple
of different ways. Must be the altitude here.

thanks for the help with this,

dave
 

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