Any way to use file path as SaveAs name?

E

Ed

I would like to save a doc with a name something like "Files in "C:\<whole
filepath>" ". Is there any way in a VBA macro to format the <filepath> so
it isn't rejected because of the "\" character?

Ed
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < Ed > écrivait :
In this message, < Ed > wrote:

|| I would like to save a doc with a name something like "Files in
"C:\<whole
|| filepath>" ". Is there any way in a VBA macro to format the <filepath>
so
|| it isn't rejected because of the "\" character?
||
|| Ed

Get the filepath into a string and replace all "\" with another character,
the "_" would be nice in this case.

If you are using Word 2000 and above, just use the Replace function. For
Word 97 you have to write your own replace function. If you need one, just
holler back and plenty of people around here can provide the code for such a
function.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
E

Ed

Thank you, Jean-Guy. I kind of thought it might be like that, but was
hoping there was a "magic wrapper" that would let me keep the "\". The only
reason is for readability for the user - I don't know that all of them are
*ahem* "quick" enough to correctly interpret "C:_My Docs_Folder1_Folder2_My
File". It *should* be obvious - but . . .

Ed
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < Ed > écrivait :
In this message, < Ed > wrote:

|| Thank you, Jean-Guy. I kind of thought it might be like that, but was
|| hoping there was a "magic wrapper" that would let me keep the "\". The
only
|| reason is for readability for the user - I don't know that all of them
are
|| *ahem* "quick" enough to correctly interpret "C:_My
Docs_Folder1_Folder2_My
|| File". It *should* be obvious - but . . .
||

You got my wondering here... Why do you need to have the full original path
in the file name?
Why not just have it in the file itself with a field? What if the file is
moved? Won't the name become irrelevant?

By the way, you cannot use ":" in a file name either.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
E

Ed

Jean-Guy Marcil said:
You got my wondering here... Why do you need to have the full original path
in the file name?

I'm building an app that will copy specified files to a folder selected by
the user. The paths to the files are saved on a doc as hyperlinks. Since
there can be more than one folder containing file copies, I can end up with
more than one doc containing file paths. I thought it might be easier for
the user to tell at a glance which list they want to reference if the docs
By the way, you cannot use ":" in a file name either.

Ahh - thanks for saving me an error! 8>)
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < Ed > écrivait :
In this message, < Ed > wrote:

|| ||| You got my wondering here... Why do you need to have the full original
path
||| in the file name?
||
|| I'm building an app that will copy specified files to a folder selected
by
|| the user. The paths to the files are saved on a doc as hyperlinks.
Since
|| there can be more than one folder containing file copies, I can end up
with
|| more than one doc containing file paths. I thought it might be easier
for
|| the user to tell at a glance which list they want to reference if the
docs
|| were named "Files saved in <this folder>", "Files saved in <that
folder>".
|| Is there a better way?
||

I am not sure I understand. You meant that the file to be named by the
procedure (the one that will include a filepath in the name) is the
reference document? In this case, do you want the reference document name to
bear the folder where it is itself located, or the folder where the files it
references were from or are going to be stored?

Or is the file name with the path for each files copied from one location to
another? If so, is it the source or the destination folder you want in the
name?

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
E

Ed

The app is actually in VB6. Using list boxes, the user navigates first to a
folder to contain the copies, and is allowed to create a new folder if
desired. This file path is captured in a string. Next the user navigates
to files and folders to copy into the "Copies of <whatever> Here" folder. A
list of the full name (including path) is added to a new doc created just to
contain the names of these files and folders.

Because the user could repeat this multiple times, creating different
"Copies of <whatever> Here" folders, I thought it would be easier to allow
an inspection of what files went where if the docs were named according to
the "Copies Here" folder - "Files Copied to C_My Docs_This Project_Copies
Here.doc". That way, if something was forgot, or misrouted, or such, the
user could keep a copy of the doc either printed or electronic to make notes
on for the next round of copies (because the next time the app is run, the
newly created doc would be saved with the same name, overwriting the
previous copy).

Do you see me setting myself up for problems?

Ed
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < Ed > écrivait :
In this message, < Ed > wrote:

|| The app is actually in VB6. Using list boxes, the user navigates first
to a
|| folder to contain the copies, and is allowed to create a new folder if
|| desired. This file path is captured in a string. Next the user
navigates
|| to files and folders to copy into the "Copies of <whatever> Here" folder.
A
|| list of the full name (including path) is added to a new doc created just
to
|| contain the names of these files and folders.
||
|| Because the user could repeat this multiple times, creating different
|| "Copies of <whatever> Here" folders, I thought it would be easier to
allow
|| an inspection of what files went where if the docs were named according
to
|| the "Copies Here" folder - "Files Copied to C_My Docs_This Project_Copies
|| Here.doc". That way, if something was forgot, or misrouted, or such, the
|| user could keep a copy of the doc either printed or electronic to make
notes
|| on for the next round of copies (because the next time the app is run,
the
|| newly created doc would be saved with the same name, overwriting the
|| previous copy).
||

OK, so you are creating a procedure to help users copy files from A to B.
At the end of the procedure, maybe in a pre-determined folder, a log file
called "Files copied to B" (Where B is the full path) is created.
This log files contains the name of all the files in B as hyperlinks.
I guess this is some kind of Backup-wizard type of thing?

I do not see any problem with this.

It would be nice if your app had a listbox containing all the names of the
previous log file created so that at a glance the user can see what has
already been copied. If the log files are not stored in a fixed location,
you could use an ini file (or a txt file) to keep track of them.
Also, there could be a warning if the user tries to copy files to an already
used folder (i.e. a log file with an identical name already exits).

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

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