Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extensions visualized

Status
Not open for further replies.

Enkay62

Programmer
Sep 5, 2003
78
0
0
IT
Hi ev'rybody.
Here's my problem.
I've created and distributed a complete workbook (excel 2000).
Now, after almost 2 years, I've realized that when I developed it I assumed that (as it happens most times) all common files extensions are always hidden (folder settings).
So, there are tons of routines that manage text and excel files.
The problem is that, if by chance extensions are shown, the program generates critical errors.
As I cannot re-write all the involved routines (too many), I thought to write just one in wb open event so as to prevent users from opening the workbook if folder settings don't hide extensions.
Here's my question.
How can I retrieve it (is there any api call or a vba simpler way)?
Any help will be appreciated.
Thank you.
Bye.
Nick.
 
I must say that if I was one of your users and you've told me that I could not see the extensions I would return your product. Very unprofessional.


The following will give you your answer. It may not work on all OS's, so you may need to use SHGetSettings instead.


Code:
Declare Sub SHGetSetSettings Lib "shell32" _
       (ByRef lpSS As Byte, ByVal dwMask As Long, ByVal bSet As Long)
Const SSF_SHOWEXTENSIONS = &H2&

Public Sub tst()
Dim Buf(0 To 6) As Byte

SHGetSetSettings Buf(0), SSF_SHOWEXTENSIONS, 0

If ExamineBit(Buf(0), 1) = True Then
    Debug.Print "true"    'SHOWEXTENSIONS is set
End If


End Sub

Function ExamineBit(Byte1 As Byte, Bit As Long) As Boolean
Dim mask As Long
      mask = 2 ^ Bit
      ExamineBit = ((Byte1 And mask) > 0)
End Function

Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top