簡単なファイルダイアログ+ファイル名取得
- ehime-db
- 2018年3月8日
- 読了時間: 1分
Private Sub cmdImport_Click()
'"Microsoft OfficeXX.X Object Library"の項目にチェック Dim intRet As Integer Dim GetFileName As String
With Application.FileDialog(msoFileDialogOpen) .Title = "ファイル選択" 'ダイアログのタイトル .Filters.Clear 'ファイルの種類 .Filters.Add "excelファイル", "*.xlsx" .Filters.Add "すべてのファイル", "*.*" .FilterIndex = 1 'ファイルの種類の初期値(1 = *.csv) .AllowMultiSelect = False '複数ファイル選択を許可しない .InitialFileName = CurrentProject.Path '初期パス intRet = .Show 'ダイアログを表示
If intRet <> 0 Then
GetFileName = Trim(.SelectedItems.Item(1)) Else
GetFileName = "" End If End With
MsgBox GetFileName DoCmd.TransferSpreadsheet acImport, 10, "T一時Import", GetFileName, True, "" End Sub
Comments