using variables in 'insertFile' and 'Open' commands

S

sylvian stone

Hi,

I wonder if somebody could answer this question - I'm sure it has been
asked many times before, but just cannot seem to figure it out.

If I define a variable for a pathname - i.e. a = "C:\MyFolder\MyPath\"
to be interpolated in either a insertFile or Open command, I could
execute:

myRange.InsertFile a & "myfile.doc"

but if tried this with

Documents.Open (a & "myfile.doc")

it will come up with a 'file not found' error.

If I hardcode the Documents.Open to:

Documents.Open ( "C:\MyFolder\MyPath\myfile.doc")

it works.


Is there a way to make 'Open' work with variables instead of specifying
the exact path (which could change in the future..)

Thanks
SS
 
D

Doug Robbins - Word MVP

Dim a As String
a = "C:\aqs\"
Documents.Open (a & "1.doc")

opens the file 1.doc in the c:\aqs folder for me

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

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