Show Desktop using VBA

pfarmer

Well-known Member
Joined
Jul 6, 2005
Messages
550
Is there a way via VBA to have the desktop items disappear?

The idea I have is when using an Excel form that no desktop items are visible so the user doesn't surf the net on a kiosk type of machine.

Perry
 
You can also just hide the Icons on the deskTop

Code:
Option Explicit


Private Declare Function FindWindowEx _
    Lib "user32" _
        Alias "FindWindowExA" ( _
            ByVal hWnd1 As Long, _
            ByVal hWnd2 As Long, _
            ByVal lpsz1 As String, _
            ByVal lpsz2 As String) _
As Long

Private Declare Function ShowWindow _
    Lib "user32" ( _
        ByVal hwnd As Long, _
        ByVal nCmdShow As Long) _
As Long

Function DesktopIconsShow()
    Dim hwnd As Long
    hwnd = FindWindowEx(0&, 0&, "Progman", vbNullString)
    ShowWindow hwnd, 5
End Function


Function DesktopIconsHide()
    Dim hwnd As Long
    hwnd = FindWindowEx(0&, 0&, "Progman", vbNullString)
    ShowWindow hwnd, 0
End Function
 
Upvote 0

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
You can also just hide the Icons on the deskTop

Code:
Option Explicit


Private Declare Function FindWindowEx _
    Lib "user32" _
        Alias "FindWindowExA" ( _
            ByVal hWnd1 As Long, _
            ByVal hWnd2 As Long, _
            ByVal lpsz1 As String, _
            ByVal lpsz2 As String) _
As Long

Private Declare Function ShowWindow _
    Lib "user32" ( _
        ByVal hwnd As Long, _
        ByVal nCmdShow As Long) _
As Long

Function DesktopIconsShow()
    Dim hwnd As Long
    hwnd = FindWindowEx(0&, 0&, "Progman", vbNullString)
    ShowWindow hwnd, 5
End Function


Function DesktopIconsHide()
    Dim hwnd As Long
    hwnd = FindWindowEx(0&, 0&, "Progman", vbNullString)
    ShowWindow hwnd, 0
End Function

I'll play with this a little bit more.

I think I figured out the set problem, will test to see if I actually did. What I think may be occurring is I already have a function that hides the buttons on the userforms title bar named the same as the one that catches the name to keep it from being hidden. This is located in the userform code so will see what occurs if I add the two together.

Perry
 
Upvote 0

Forum statistics

Threads
1,216,060
Messages
6,128,545
Members
449,457
Latest member
ncguzzo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top