Solved Fix code to enable/disable "Hide extensions for known file types option" From Folder Option

Kha

Member
Local time
Today, 08:16
Joined
Sep 4, 2022
Messages
57
Hi,
Please help me to fix this code, to make it works
I got Compile errors

Code:
'The state of the Hide extensions for known file types option (SSF_SHOWINFOTIP)
Public Function fnIShellDispatch4GetSetting()
    Dim objIShellDispatch4 As Shell
    Set objIShellDispatch4 = New Shell
    If (Not objIShellDispatch4 Is Nothing) Then
        Dim vReturn As Variant
        Dim SSF_SHOWINFOTIP As Long
        SSF_SHOWINFOTIP = 1
        vReturn = objIShellDispatch4.GetSetting(SSF_SHOWINFOTIP)
        Debug.Print vReturn
    End If
    Set objIShellDispatch4 = Nothing
End Function


1662747775920.png
 
can you show me how it to fix it?
 
Go back to where you got the code, as they generally tell you what reference you need with the code.
 
Well it says you need Shell32.dll so look for what reference that would be.
 
I tried searching but I didn't find the solution
my MS Office is 365 64 bit
1662755002030.png


1662754969169.png
1662754952224.png
 
Another way is to read the registry?
See this link for values, then google how to read registry with vba.
Curious as to why you want this?
The extension is still there, just hidden, so you can still open filename.csv etc ?
 
  • Like
Reactions: Kha
I do not think that code enables/disables anyway, just shows whether set or not.?
It worked for me when I set the correct reference, and does what I suspected.
I get True on the Debug.Print and I ALWAYS show file extensions?

1662755742164.png

1662755872089.png
 
  • Like
Reactions: Kha
I do not think that code enables/disables anyway,
Yes you are correct,
it seems this code that it is only to verify its effectiveness True of False :(
Do yo have code that can make enable/disable to this option please?
 
No, but I linked to code to set the registry.? Google how to write to registry with VBA and those settings.
Again, why do you want this?
 
  • Like
Reactions: Kha
Well I do not know. either I would just Google.
 
Out of interest in why would you want to change a user's settings in that way? The file has the extension whether or not you can see it.
 
Code:
' arnelgp
Public Function ShowHideFileExtensions(Optional ByVal Show As Boolean = True)
Dim k As String, sh As Object, value As Integer
k = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\HideFileExt"
Set sh = CreateObject("WScript.Shell")
value = CInt(Show) + 1
sh.RegWrite k, value, "REG_DWORD"
End Function

it did change the value in the registry but nothing happens?
maybe need to Re-Start the Explorer or a Reboot?
 
Last edited:

Users who are viewing this thread

Back
Top Bottom