生成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

posted on 2011-09-01 16:17  idjump  阅读(359)  评论(0)    收藏  举报

导航