Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to use the current folder using VBA

Posted on 2009-05-12
4
Medium Priority
?
689 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Microsoft Word is a program we have all encountered at some point, but very few of us have dug deep into its full scope of features, let alone customized it to suit our needs. Luckily making the ribbon (aka toolbar, first introduced in Word 2007) wo…
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.
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…

636 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