Monday, 22 October 2012

How To Open a Special Folder

Excel VBA Macro To Open a Special Folder
Sub GetSpecialFolder()
'Special Folders are : 
'AllUsersDesktop, AllUsersStartMenu
'AllUsersPrograms, AllUsersStartup, Desktop, Favorites
'Fonts, MyDocuments, NetHood, PrintHood, Programs, Recent
'SendTo, StartMenu, Startup, Templates

'Get Favorites Folder and Open it
Dim WShell As Object
Dim SpecialPath As String
  
Set WShell = CreateObject("WScript.Shell")
SpecialPath = WShell.SpecialFolders("Favorites")
MsgBox SpecialPath
'Open Folder in Explorer
Shell "Explorer.Exe " & SpecialPath, vbNormalFocus
       
'The WindowStyle Named Argument has These Values:
'Constant Value Description
'vbHide : 0 Window is hidden and focus is passed to the hidden window. The vbHide constant is not applicable on Macintosh platforms.
'vbNormalFocus : 1 Window has focus and is restored to its original size and position.
'vbMinimizedFocus : 2 Window is displayed as an icon with focus.
'vbMaximizedFocus : 3 Window is maximized with focus.
'vbNormalNoFocus : 4 Window is restored to its most recent size and position. The currently active window remains active.
'vbMinimizedNoFocus : 6 Window is displayed as an icon. The currently active window remains active.

End Sub

No comments:

Post a Comment

Follow Me by Email

ExcelKingdom-Popular Posts

ExcelKingdom-Random Posts