有了VBA,我怎么能检查,如果在Windows资源管理器,对已知文件类型的文件扩展名被隐藏?
-
19-09-2019 - |
题
不需打开Windows资源管理器。我想从Word VBA检查这个。
感谢。
编辑:
此代码的工作现在:
Set WshShell = CreateObject("WScript.Shell")
If WshShell.RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\HideFileExt") = 0 Then
MsgBox Prompt:="In Windows Explorer, set the folder options to hide file extensions of known file types." _
& vbCrLf & vbCrLf & " This prevents the file extension from appearing as part of the document number in" _
& "the document body and page headers.", Buttons:=vbOKOnly + vbCritical, Title:="Critical"
End If
解决方案
您需要查询注册表值
HKEY_CURRENT_USER \软件\微软\的Windows \ CurrentVersion \ Explorer中\高级\ HideFileExt
扩展被显示,如果该值为0,并隐藏如果它是1。
可以使用 RegRead 方法WshShell对象上读取此值。您可以在VBA项目添加到Windows脚本宿主对象模型类型库的引用,当您使用WshShell对象获得强类型。
不隶属于 StackOverflow