• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 695
  • Last Modified:

How to use the current folder using VBA

I'm currently writing a small macro that when run will find key words in a document and insert a file at that location. The file to be inserted will always be in the same folder as the main document. So my question is how do I tell the macro to get the file in the same folder? The reasoning is that if I move the folder to another computer or location it will always find the file.

Hope this makes sense

Many thanks in advance.
  • 2
1 Solution
currentproject.path , this will get files from the location where the file is running from everytime..

Shanmuga SundaramDirector of Software EngineeringCommented:
Did you try using


in the macro. This should give you the current folder name with full path.
daleoranAuthor Commented:
Sorry can't seem to get them to work. I'm using this

Selection.InsertFile FileName:=Path & Count & ".txt"

where Path is either currentproject.path or ThisDocument.Path

daleoranAuthor Commented:
Answer was

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now