current drive and directory

  • Thread starter Jeffery B Paarsa
  • Start date
J

Jeffery B Paarsa

Hello,

In a VBA, is there any way that I can find out the current drive and
directory that I am currently using? I have a few templates that all are
stored in a single directory. I would like to make the VBA codes inside of
these Word Templates independent of drive letter and directory name that they
are stored. Inside of these codes I would like to be able to find out what
drive and directory I am currently executing the code so based on that I
could open the next template. Any idea?
 
J

Jonathan West

Jeffery B Paarsa said:
Hello,

In a VBA, is there any way that I can find out the current drive and
directory that I am currently using? I have a few templates that all are
stored in a single directory. I would like to make the VBA codes inside
of
these Word Templates independent of drive letter and directory name that
they
are stored. Inside of these codes I would like to be able to find out
what
drive and directory I am currently executing the code so based on that I
could open the next template. Any idea?

Application.MacroContainer.FullName gives you the full pathname of the
template containing the code being run


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
J

Jeffery B Paarsa

Thanks, I will give this one a shut too but right after I posted this
question I stumble to "FileSystem.CurDir" and I was able to get to the string
of the current drive and directory. But FileSystem.CurDir does not work whey
you use it in the Insert Field INCLUDETEXT on the Header and Footer section.
 
J

Jean-Yves

Hi Jeffery,

use CurDir. Paste in VBA , press the F1 key and you will get all info.
Regards
JY
 
C

Cindy M.

Hi =?Utf-8?B?SmVmZmVyeSBCIFBhYXJzYQ==?=,
I will give this one a shut too but right after I posted this
question I stumble to "FileSystem.CurDir" and I was able to get to the string
of the current drive and directory. But FileSystem.CurDir does not work whey
you use it in the Insert Field INCLUDETEXT on the Header and Footer section.
You have to be careful with CurDir. CurDir might not be the same folder as the
current document, or the template containing the macro.

Jonathan gave you the way to get the path for the template containing the macro.

Nothing in your original message even hints at your wanting to use IncludeText
in the header/footer section. You certainly CANNOT use VBA *in* field codes;
field codes do not support VBA. If the content you're linking into a document
isn't in the same file, or file path, of the current document, then you have to
use the complete file path. The CurDir is irrelevant, because it will always be
the folder which the Word APPLICATION last accessed.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 

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