ActiveDocument.Path

S

Steve

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
 
J

Jay Freedman

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

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...
 
S

Steve

Jay Freedman said:
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...

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
 
J

Jay Freedman

Steve said:
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

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.
 
S

Steve

Jay Freedman said:
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.

Wise words. If only I was young enough to remember them!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top