PDA

View Full Version : How to get object or data source from current folder of the file?



eie319
07-21-2012, 01:14 AM
Hi, I have a Word file with saved macro that will get the self Word file as an object and get data source from an Excel file. My question is instead of specific the path like "C:\word.docm" or "C:\excel.xls", how to let system retrieve them from the current folder of the Word file? I have tried to type "word.docm" and "excel.xls" instead but did not work.

macropod
07-21-2012, 09:11 PM
You can always retrieve the current document's path with:
ActiveDocument.Path
you could use this for relative referencing, thus:
StrFile = ActiveDocument.Path & "\excel.xls"