View Single Post
 
Old 05-30-2019, 04:12 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,980
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

Dave, I initially thought your code wouldn't work on paths which include spaces and this might be why it didn't work on the network path you were using.

If this is the case, you would need to enclose the pathname in double quotes
Shell Environ("windir") & "\Explorer.exe """ & ActiveDocument.Path & """", vbNormalFocus

However, on my machine both your code and my variation worked on both local and network paths. Perhaps you have an older version of Windows and it might be worth exploring on your machine.

BUT, If you want to actually open a second file with exactly the same name as the current document but in a different folder path then you could use a string replace function to get the fullname along the lines of the following aircode

Dim sNewFile as string, sOldFile as string
sNewFile = ActiveDocument.Fullname
sOldFile = Replace(sNewFile,"NewReport","OldReport")
Documents.Open sOldFile
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote