Created
January 31, 2012 00:10
-
-
Save kumatti1/1707713 to your computer and use it in GitHub Desktop.
VBAでのIFileDialog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
自作したTypeLibに参照設定 | |
Option Explicit | |
Declare Sub CoTaskMemFree Lib “Ole32.dll” (ByVal pv&) | |
Declare Function lstrlenW& Lib “Kernel32.dll” (ByVal lpString&) | |
Declare Sub RtlMoveMemory Lib “Kernel32.dll” (ByVal Destination&, ByVal Source&, ByVal length&) | |
Sub hoge() | |
Dim o As IFileOpenDialog | |
Dim si As IShellItem | |
Dim tmp&, hr&, length&, s$ | |
Set o = New FileOpenDialog | |
hr = o.Show(Application.Hwnd) | |
’ 非選択時 | |
If hr < 0 Then Exit Sub | |
’ IShellItemの参照のセット | |
Set si = o.GetResult | |
’ 選択したパスを得る | |
si.GetDisplayName SIGDN_FILESYSPATH, VarPtr(tmp) | |
length = lstrlenW(tmp) | |
s = String$(length, 0) | |
RtlMoveMemory StrPtr(s), tmp, length * 2 | |
CoTaskMemFree tmp | |
MsgBox s | |
End Sub |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://www1.axfc.net/uploader/File/so/74744 | |
# アップローダーに置きました。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment