CommandButtonを押したら、フォルダを開くようにしたいのですが、できるでしょうか?
“C:\WINDOWS”や“\\PC\共有”といったフォルダを開きたいです。
御指導お願いします。
普通にコモンダイアログ使えば良いんじゃないですか?
編集 削除たとえば
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" _
(ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Private Sub Command1_Click()
ShellExecute Me.hwnd, "explore", “C:\WINDOWS”や“\\PC\共有”"", "", 1&
End Sub
とか?
訂正
ShellExecute Me.hwnd, "explore", “C:\WINDOWS”や“\\PC\共有”"", "", 1&
↓
ShellExecute Me.hwnd, "explore", "C:\WINDOWS", "", "", 1&
試してみたのですが、何も反応が起こりませんでした。
アドレス部の"C:\WINDOWS"を消すとエクスプローラは立ち上がりました。
どうすれば良いのでしょうか?
すいません。
"C:\WINDOWS"は何も反応がなかったのですが、"\\PC\共有"では立ち上がりました。
ん〜謎です。
あと、欲を言えば左側にツリーで出てきているので、それを無くしたいのですが、
できるでしょうか?
CreateObject("Shell.Application").Explore CVar("C:\WINDOWS")
とか。
> 左側にツリーで出てきているので、それを無くしたいのですが
であれば、
CreateObject("Shell.Application").Open CVar("C:\WINDOWS")
とか。
ShellExecute Me.hwnd, vbNullChar,"C:\WINDOWS", vbNullChar, vbNullChar, vbNormalFocus
でだめかな?
解決できました。
ありがとうございました。
>"C:\WINDOWS"は何も反応がなかったのですが
ここの部分、とんでもないことにアドレス間違って入力してました。
お騒がせして申し訳ない。