はい、ファイルを開くことができます。これを行う方法の例とコードをテストするサブルーチンを次に示します。下記のコードを変更してください。
既存のボタンを変更するクリックすると、図のような「OpenFile」行が追加されます。 完全なパスとファイル名を渡します。 あなたのcomboBoxには、comboBoxの列としてのパスがあるとしますか?ない 場合は、非表示の列
Private Sub cmdRead_Click()
' whatever code you have or need
OpenFile Me.cboXXXX.Column(1) ' Change to the name of your combobox AND column # of Full Path
' whatever other code you want
End Sub
'---- Create a new module and paste all of the following code in it
Option Explicit
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
Public Function OpenFile(sFileName As String)
On Error GoTo Err_OpenFile
OpenFile = ShellExecute(Application.hWndAccessApp, "Open", sFileName, "", "C:\", 1)
Exit_OpenFile:
Exit Function
Err_OpenFile:
MsgBox Err.Number & " - " & Err.Description
Resume Exit_OpenFile
End Function
Public Function TestOpeningFile()
On Error GoTo Err_TestOpeningFile
OpenFile "C:\Windows\Win.ini"
Exit_TestOpeningFile:
Exit Function
Err_TestOpeningFile:
MsgBox Err.Number & " - " & Err.Description
Resume Exit_TestOpeningFile
End Function
申し訳ありません、情報をありがとうございます。私は、コマンドボタンに任意の行が表示されないので、私はコマンドボタンに上記のコードを割り当てる必要がありますか?または、私はちょうどユーザーフォームに挿入する必要がありますか? – Janek
私は、コントロールの名前を変更する必要がある '一般的な呼び出し'を使用して、1分以内に回答を更新します。それはトリックを行うだろう... –
とにかく私はウェブサイト上のマクロをアップロードすることができますか?私は、何が起こっているかを見るのがはるかに簡単になると思う。 – Janek