生成word时,需要过滤或替换一些字符。

在给文件重命名时,会有如上提示。所以,在生成word是需要进行过滤或替换,如下是过滤:
Function RepTitle(Title) If Title<>"" Then title=replace(title,"/","") If Title<>"" Then title=replace(title,"/","") If Title<>"" Then title=replace(title,":","") If Title<>"" Then title=replace(title,"*","") If Title<>"" Then title=replace(title,"?","") If Title<>"" Then title=replace(title,""","") If Title<>"" Then title=replace(title,"<","") If Title<>"" Then title=replace(title,">","") If Title<>"" Then title=replace(title,"|","") RepTitle=Title end Function
对于这四个字符“: ? < >”,也可执行替换为中文的字符“:?《》”。如下是替换:
Function RepTitle(Title) If Title<>"" Then title=replace(title,"/","") If Title<>"" Then title=replace(title,"/","") If Title<>"" Then title=replace(title,":",":") If Title<>"" Then title=replace(title,"*","") If Title<>"" Then title=replace(title,"?","?") If Title<>"" Then title=replace(title,""","") If Title<>"" Then title=replace(title,"<","《") If Title<>"" Then title=replace(title,">","》") If Title<>"" Then title=replace(title,"|","") RepTitle=Title end Function
浙公网安备 33010602011771号