daleoran
asked on
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.
Hope this makes sense
Many thanks in advance.
Did you try using
ThisDocument.Path
in the macro. This should give you the current folder name with full path.
ThisDocument.Path
in the macro. This should give you the current folder name with full path.
ASKER
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
Selection.InsertFile FileName:=Path & Count & ".txt"
where Path is either currentproject.path or ThisDocument.Path
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
currentproject.path , this will get files from the location where the file is running from everytime..