Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2005

Tip: Looking for answers? Try searching our database.

ActiveDocument.Path

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steve - 03 Nov 2005 23:59 GMT
Hi

I am writing a .dot file that tries to open a .doc file saved with a VBA
generated name stored in a VBA created directory structure. If the file
exists, it opens. If not, a new file is created complete with headings,
tables, etc. Everything works well now with the exception that I need to
hard code the top level of folder so it can be moved to a different folder
structure without the need for me to hard code the new location.

sFilePath should pick up the directory of the .dot file rather than the
newly created Document1 (which, of course, has no path until saved). Is
there a way I can pick up the path of the .dot file?

sFilePath = "H:\Daily Operational Reports" ' ActiveDocument.Path does not
work
On Error Resume Next
sFilePath = sFilePath & "\" & Format(Date, "YYYY")
...

Steve
Jay Freedman - 04 Nov 2005 04:57 GMT
>Hi
>
[quoted text clipped - 16 lines]
>
>Steve

If the document is based on the template whose path you want, try

 ActiveDocument.AttachedTemplate.Path

Does this really have a relation in your scheme to the location where
the document will be saved? Normally that isn't true...

--
Regards,
Jay Freedman
Microsoft Word MVP        FAQ: http://word.mvps.org
Steve - 04 Nov 2005 21:55 GMT
>>Hi
>>
[quoted text clipped - 28 lines]
> Jay Freedman
> Microsoft Word MVP        FAQ: http://word.mvps.org

Jay

Thank you. That works as requested.

In this case, I had a directory structure set up on a common drive with the
top level hard coded into the template. When I went to another work location
for a few weeks, somebody decided to restructure the LAN resulting in the
recreation of the old top level folder and two sub-folders.

The other part of the problem is my intention to distribute this to a second
work area who use a different common drive identifier.

Dynamically pointing to the top level folder will overcome the above. All I
need do now is cross my fingers that users will shortcut to the .dot file as
instructed rather than copy it ... On reflection,  the hard-coded version
makes certain the most recent document always sits in a specified location,
making it easy for me to find. Do I allow fools the freedom to restructure
the common drive to their hearts content or sit back and laugh when they
can't work out why 'that' folder keeps appearing after being moved ...
decisions, decisions.

Steve
Jay Freedman - 04 Nov 2005 23:33 GMT
>>> Hi
>>>
[quoted text clipped - 53 lines]
>
> Steve

One of my favorite aphorisms is "Nothing is foolproof because fools are so
ingenious." That's why hard-coded addresses and schemes to prevent people
from modifying systems are doomed to failure. If at all possible, design for
the certainty that everything will change under you, and that mistakes are
inevitable. If you think you can outsmart the fools, the laugh will
eventually be on you.

Signature

Regards,
Jay Freedman
Microsoft Word MVP          FAQ: http://word.mvps.org

Steve - 06 Nov 2005 00:15 GMT
> One of my favorite aphorisms is "Nothing is foolproof because fools are so
> ingenious." That's why hard-coded addresses and schemes to prevent people
[quoted text clipped - 3 lines]
> inevitable. If you think you can outsmart the fools, the laugh will
> eventually be on you.

Wise words. If only I was young enough to remember them!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.