LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Saving in VBA to a particular location

Maury Markowitz wrote on 5/7/2012 :
On May 7, 12:55*pm, GS wrote:
Check out 'ThisWorkbook.Path'


But it may not be the same path as where the user opened it. That's
the use-case I'm trying to address.

Is there a way to compare paths that may be network or shortcut
degenerate to the same place? I know there's a term for this, but I
can't recall it.


That will ALWAYS be the path to the file that contains the VBA that's
running. So if, as you say, this workbook has code that runs
automatically when it's opened then that code will ref that workbook's
path using the syntax I gave you. It doesn't matter where the workbook
is stored, 'ThisWorkbook.Path' will always return its location.

If it's a network path then it will have a UNC path ("\\server\share")
instead of a local path ("C:\MyFolder"). This will always be relative
to the machine that opened the file. *Notice* the difference in the 1st
2 characters of the paths; network paths start with "\\" while local
paths start with a drive letter and a colon.

Paths returned by the 'GetSaveAsFilename' dialog also return the same
path info. Now maybe you're talking about a user selecting a local
folder that's 'mapped' to a network location. In this case that folder
is actually a 'Namespace' link to a network location and so does not
return a valid path via the 'SaveAs' dialog. Windows uses a redirect to
get to the actual network location and so is why you want the UNC path
when doing SaveAs. IOW, the mapped folder is not the 'Absolute PIDL' of
the network location and that's why you can't use it as a path.

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Prevent saving on specified location Basta1980 Excel Programming 0 June 11th 08 09:11 AM
Saving to a specific location Sandy Excel Programming 9 June 9th 07 05:57 PM
saving w/sheet to different location Nigel[_21_] Excel Programming 7 October 8th 05 12:17 PM
Saving Excel in more than one location Mark C via OfficeKB.com Excel Programming 3 August 16th 05 05:57 AM
Saving in a location Greg Brow Excel Programming 2 February 4th 05 02:57 PM


All times are GMT +1. The time now is 10:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"