2016-07-15 8 views
1

次のスクリプトコードを使用して、コードを初めて実行したときにフィルタとタイトルの設定が機能しません。MS Access FileDialog Filterが元のロードでは機能しません

提案がありますか?

Set f = Application.FileDialog(msoFileDialogFilePicker) 

If f.Show = True Then 

With f 
    .Title = "Choose Excel File(s) to Import" 
    .Filters.Clear 
    .Filters.Add "Excel Files", "*.xlsx" 
    .AllowMultiSelect = True 

    For Each varfile In .SelectedItems 
     MsgBox "IMPORTING: " & varfile 
     tblImport = varfile 
     DoCmd.TransferSpreadsheet acImport, 10, "Parts", tblImport, True 
    Next varfile 
End With 

答えて

1

Showメソッドを呼び出す前にFileDialogプロパティを設定します。

Set f = Application.FileDialog(msoFileDialogFilePicker) 

With f 
    .Title = "Choose Excel File(s) to Import" 
    .Filters.Clear 
    .Filters.Add "Excel Files", "*.xlsx" 
    .AllowMultiSelect = True 
    If .Show = True Then 
     For Each varfile In .SelectedItems 
      MsgBox "IMPORTING: " & varfile 
      tblImport = varfile 
      DoCmd.TransferSpreadsheet acImport, 10, "Parts", tblImport, True 
     Next varfile 
    End If 
End With 
関連する問題