preventing / converting 'illegal' characters in file-save text string
This should take such a small amount of time, why not just "fix" the name
Dim varr as Variant, fName as String
varr = Array("|",":","/","\")
for i = lbound(varr) to ubound(varr)
fname = replace(fname,varr(i),"")
Next
Where fName would hold the just the proposed file name (not including the
drive/path)
--
Regards,
Tom Olvy
"Tim" wrote in message
...
Hi All,
some help would be gratefully appreciated: i have written a small piece of
vba to create a file name from a mixture of comboboxes (userform) and
cells
(worksheet), then saves the file (saveas).
it works fine, but i want some automated way of making sure no 'illegal'
characters are used in those 'boxes / cells (eg, ':' or '\'). is there a
single instruction that looks for all such charatcers (that i could then
use
in a find-replace or if-then statement?). currently, it causes an error
and
stops the macro or if '\' occurs somewhere in the string, it results in an
extra directory being formed (named from the contents to the left of the
'\'), which is at best confusing!
tia,
tim
|