这样,我们对SaveToFileEx函数进行一些修改,让其先截取路径和文件名,存放于onlyPath和onlyFileName中,再对onlyFileName进行扩展名截取。将tmpPath=Split(Path,".")(0)修改为以下代码:
for i=len(Path) to 1 step -1
if mid(Path, i, 1) = "/" or mid(Path, i, 1) = "/" then exit for
next
onlyPath = left(Path, i)
onlyFileName = right(Path, len(Path) - i)
tmpFileName = Split(onlyFileName,".")(0)
然后将写文件的代码改成这样:
oFileStream.SaveToFile OnlyPath & tmpFileName & "." & FileExt,2
进行了这样的修改,再运行就没有问题了。