Monday, October 22, 2012

How to Open a Special Folder using VBA Macro

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 Window Style 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

Thanks,Tamatam

No comments:

Post a Comment

Hi User, Thank You for visiting My Blog. Please post your genuine Feedback or comments only related to this Blog Posts. Please do not post any Spam comments or Advertising kind of comments which will be Ignored.

Featured Post from this Blog

How to compare Current Snapshot Data with Previous Snapshot in Power BI

How to Dynamically compare two Snapshots Data in Power BI Scenario: Suppose, we have a sample Sales data, which is stored with Monthly Snaps...

Popular Posts from this Blog