マイドキュメントやデスクトップなど、特殊フォルダのパスを取得する関数です。
関数概要
- 関数名: FNCGetSpecialFolderPath
- 入力引数; P_IN_WSHSpecialFolder ( 独自型 WSHSpecialFolder ) : Desktop や MyDocuments など、特殊フォルダ名を設定します。
- 出力引数: P_OUT_SpecialFolderPath ( String 型) : 特殊フォルダのパスが設定されます。
- 返り値:リターンコードが返却されます。
実行例
- 準備中
ダウンロード
UsefulEdgeではよく使うVBA処理を共通クラスとして提供しています。
以下からダウンロードが可能です。
使用方法
- 準備中
ソースコード
'-----------------------------------------------------------------
' 特殊フォルダパスを取得する
' AllUsersDesktop
' AllUsersStartMenu
' AllUsersPrograms
' AllUsersStartup
' Desktop
' Favorites
' Fonts
' MyDocuments
' NetHood
' PrintHood
' Programs
' Recent
' SendTo
' StartMenu
' Startup
' Templates
'-----------------------------------------------------------------
Function FNCGetSpecialFolderPath(P_IN_WSHSpecialFolder As WSHSpecialFolder, P_OUT_SpecialFolderPath As String) As Integer
On Error GoTo ErrorHandler
FNCGetDesktopPath = Me.ReturnError
Dim path As String, WSH As Variant, OpenFileName As String
Set WSH = CreateObject("WScript.Shell")
path = WSH.SpecialFolders(P_IN_WSHSpecialFolder)
P_OUT_SpecialFolderPath = path
FNCGetDesktopPath = Me.ReturnNomal
Exit Function
ErrorHandler:
MsgBox Err.Number & ":" & Err.Description, vbCritical & vbOKOnly, "エラー"
FNCGetDesktopPath = Err.Number
Exit Function
End Function
ソースコード説明
- 準備中
ExcelVBAを実務で使い倒す技術 [ 高橋宣成 ]
価格:1944円(税込、送料無料) (2019/7/23時点)
楽天で購入
](https://hb.afl.rakuten.co.jp/hgc/156e5f8f.d5d194cd.156e5f90.9ce91fc7/?pc=https%3A%2F%2Fitem.rakuten.co.jp%2Fbook%2F14714310%2F%3Fscid%3Daf_pc_bbtn&m=http%3A%2F%2Fm.rakuten.co.jp%2Fbook%2Fi%2F18413544%2F%3Fscid%3Daf_pc_bbtn&link_type=picttext&ut=eyJwYWdlIjoiaXRlbSIsInR5cGUiOiJwaWN0dGV4dCIsInNpemUiOiIyNDB4MjQwIiwibmFtIjoxLCJuYW1wIjoicmlnaHQiLCJjb20iOjEsImNvbXAiOiJkb3duIiwicHJpY2UiOjEsImJvciI6MSwiY29sIjoxLCJiYnRuIjoxfQ==)
コメント