test for existence of file(s)

S

scott

hi

I've modified some VBA for office code to fetch pricing details from a file
instead of being embedded in the body of the code iteslf (the code is
embedded into a word .dot file). now when they change their prices, they can
update the pricing file instead of calling me in (doing myself out of a job,
but it saves a journey in !!)

I'm not quite sure how to handle the code if they ever delete/move/corrupt
the pricing file ! currently, if the file is unreachable for any reason, the
code will just crap out

I looked for an 'exists' function, but it only applies to bookmarks and
tasks, not files

I presume I need to just try and open the file, and then handle what it
returns in the form of a sucess/fail result

can anyone confim this, or is there some clever function for doing this sort
of thing ? office version is xp (2002 ?)

many thanks

_scott
 
S

Steve Lang

Hi Scott,

Use the Dir() Function. it will return the string of the filename if it
exists, an empty string if it doesn't.

HTH and have a great day!

Steve
 

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