|
| Menuへ |
| ランチャーソフトを作ってみよう |
Step 2 見出しと参照ボタン
|
| シートイベント |
下記のコードに変更してください。
|
Option Explicit
'コマンドボタン クリックイベント
Private Sub CommandButton1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
'右クリックの場合
If Button = 2 Then
ButtonNo = 1
ButtonCaption = CommandButton1.Caption
'ファイル指定フォームを開く
UserForm1.Show
End If
End Sub |
|
|
| ユーザーフォームイベント |
下記のコードを追加してください。
|
'参照ボタン
Private Sub CommandButton1_Click()
Dim sfina As String
'ファイル選択ダイアログ
sfina = SelectFile_single
If sfina <> "" Then
TextBox2 = sfina
End If
End Sub
Private Sub UserForm_Initialize()
TextBox1 = ButtonCaption
End Sub
|
|
|
| 標準モジュールコード |
下記のコードを追加してください。
|
Option Explicit
Public ButtonNo As Integer
Public ButtonCaption As String
'ファイル選択ダイアログ
Public Function SelectFile_single()
Dim sfile As String
Dim i As Integer
Dim s As String
sfile = Application.GetOpenFilename("ファイルを選択してください (*.*), *.*")
If sfile = "False" Then
SelectFile_single = ""
Else
SelectFile_single = sfile
End If
End Function |
|
|
| シートとユーザーフォーム |
|
コマンドボタンを右クリックすると、ファイル指定のユーザーフォームが開きます。 |
|
 |
|
|
|
Topへ
|
■このサイトの内容を利用して発生した、いかなる問題にも一切の責任は負いませんのでご了承下さい。■
当ホームページに掲載されているあらゆる内容の無許可転載・転用を禁止します。
Copyright (c) 2006 excel_ninpou All rights reserved. |
|
|