Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 06-07-2023, 04:42 PM
Guessed's Avatar
Guessed Guessed is offline How to refer to a file in the same directory Windows 10 How to refer to a file in the same directory Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,185
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

You will need to be explicit in providing the actual path. In VBA you could use
Code:
ThisDocument.Path & Application.PathSeparator & "My Doc.docx"  'or
ActiveDocument.Path & Application.PathSeparator & "My Doc.docx"
ThisDocument is the file where the macro is sitting
ActiveDocument is the document which is currently active (on top)
Application.PathSeparator is a tortuous way to write \ but we use it in case the code is being used on a Mac, in which case it becomes ":" because that is how a Mac separates folders
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Strip out numbers from file names in a directory. JustJim Word VBA 2 10-20-2021 06:40 PM
How to refer to a file in the same directory Using Word VBA to change file names in a directory sg11 Word VBA 4 03-22-2018 04:25 AM
How to refer to a file in the same directory Changing file directory from a temp folder dwirony Word VBA 6 12-13-2016 09:41 PM
How to refer to a file in the same directory Replacing jpg file in each file of a directory hklein Word VBA 4 10-14-2013 04:40 PM
Auto-File Naming/ Default Directory Saves sgill32 Word 2 11-06-2008 02:12 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:21 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft