Sub OpenFileExample()
Dim filePath As String
filePath = Application.GetOpenFilename("CSV文件 (*.csv),*.csv,DAT文件 (*.dat),*.dat,kml文件 (*.kml),*.kml", , "选择要打开的文件")
If filePath <> "False" Then
' 用户选择了文件
' 在这里可以添加处理文件的代码
Dim lineCount As Integer
lineCount = 0
Open filePath For Input As #1
Do Until EOF(1)
Line Input #1, textLine
lineCount = lineCount + 1
Loop
Close #1
Else
Exit Sub
End If
Debug.Print lineCount
End Sub