1

无需打开 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
4

1 回答 1

5

需要查询注册表值

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\HideFileExt

如果该值为 0,则显示扩展,如果为 1,则隐藏。

您可以使用 WshShell 对象上的RegRead方法来读取此值。您可以在 VBA 项目中添加对 Windows 脚本宿主对象模型类型库的引用,以便在使用 WshShell 对象时获得强类型。

于 2009-07-22T11:43:27.017 回答