?
Solved

How to use the current folder using VBA

Posted on 2009-05-12
4
Medium Priority
?
691 Views
Last Modified: 2012-08-13
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.
0
Comment
Question by:daleoran
  • 2
4 Comments
 
LVL 9

Expert Comment

by:drequinox
ID: 24365972
try
currentproject.path , this will get files from the location where the file is running from everytime..



0
 
LVL 17

Expert Comment

by:Shanmuga Sundaram
ID: 24366530
Did you try using

ThisDocument.Path

in the macro. This should give you the current folder name with full path.
0
 
LVL 10

Author Comment

by:daleoran
ID: 24369408
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

0
 
LVL 10

Accepted Solution

by:
daleoran earned 0 total points
ID: 24594384
Answer was

ActiveDocument.path
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nice table. Huge mess. Maybe this was something you created way back before you figured out tabs or a document you received from someone else. Either way, using the spacebar to separate the columns resulted in a mess. Trying to convert text to t…
Preface: When I started this series, I used the term CommandBars because that is the Office Object class that it discusses. Unfortunately, when Microsoft introduced Office 2007, they replaced the standard Commandbar menus with "The Ribbon" and rem…
This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question