Special Folders' Path (VBA)

The following code displays path of all special folders in Windows on the worksheet. Copy the following code in a general module and run(F5).
Sub GetSpecialFolderPaths() Dim WSHShell As Object Dim strPath As String Dim strFolderName As String Dim intLoop As Integer Set WSHShell = CreateObject("Wscript.Shell") For intLoop = 0 To WSHShell.SpecialFolders.Count - 1 strPath = WSHShell.SpecialFolders(intLoop) strFolderName = Mid(strPath, InStrRev(strPath, Application.PathSeparator) + 1, 9999) ActiveSheet.Cells(intLoop + 1, 1) = strFolderName ActiveSheet.Cells(intLoop + 1, 2) = strPath Next intLoop Set WSHShell = Nothing End Sub
»
- Vishesh's blog
- Add new comment
- 1739 reads

Recent comments
6 hours 20 min ago
9 hours 44 min ago
10 hours 6 min ago
16 hours 9 min ago
17 hours 1 min ago
1 day 7 hours ago
1 day 7 hours ago
1 day 11 hours ago
1 day 19 hours ago
2 days 14 hours ago