如何使用VBA从硬盘打开csv文件而不提供文件的特定位置。
答案 0 :(得分:0)
Sub GetCSV()
Dim sFile As String
Dim wb As Workbook
'You can get fancier with the "filter" argument, see the internet for more info
sFile = Application.GetOpenFilename("*.csv,*.csv")
'False means they clicked cancel
If sFile <> "False" Then
Set wb = Workbooks.Open(sFile)
'do stuff
wb.Close
End If
End Sub