Att*_*tti 6 unicode excel vba excel-vba
我正在使用Dir选择基于标准的文件列表,然后将它们存储在字符串数组中.然后我遍历数组并处理文件.
如何使用unicode字符处理文件名?
我试着这样做,StrConv但没有帮助.
vfile = Dir(vCurrDir & vCrit, vbNormal) 'vCrit is something like *test*
Run Code Online (Sandbox Code Playgroud)
然后我会尝试访问文件的属性,如下所示:
vfilename = vCurrDir & "\" & vfile
Set objFSO = CreateObject("Scripting.FileSystemObject")
vDateMod = objFSO.GetFile(vfilename).datelastmodified
Run Code Online (Sandbox Code Playgroud)
在最后一行,我收到一条错误消息,指出找不到文件.这仅适用于具有unicode字符的文件名.
这里有另一篇关于此的帖子:在VBA中使用Unicode文件名(使用Dir,FileSystemObject等),但它没有t solve the problem withDir`.
我的示例:VBA(watch)c:\ my-test-file.pdf Unicode:c:\ my-test-file.pdf
(你不能在这里看到区别但是如果你复制名称并将它们粘贴到Notepad ++中,你会看到两个文件的破折号是不同的字符,VBA正在将unicode破折号字符转换为windows locale破折号)
或链接问题的示例:3_Połish.txt(在Unicode中)与3_Polish.txt(在VBA中)
And*_*ykh -1
尝试使用 BuildPath https://msdn.microsoft.com/en-us/library/office/gg251615.aspx而不是
vfilename = vCurrDir & "\" & vfile
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1993 次 |
| 最近记录: |