VBA 如何取得选中文件的路径?谢谢!!!

来源:百度知道 编辑:UC知道 时间:2024/05/31 11:08:34
theSh = Application.GetOpenFilename("Txt Files (*.txt), *.txt", , , , True)
If VarType(theSh) = vbBoolean Then
MsgBox "取消"
Else
MsgBox "有 " & UBound(theSh) & " 个文本将要被导入~"
End If
Range("C3").Value = ??????????????
End Sub

上文可以选取多个txt文本
请教如何修改一下可以做到只能够选择一个txt文本?
“??????????????”处如何取得该文本的绝对路径 谢谢!!

可以改成:
theSh = Application.GetOpenFilename("Txt Files (*.txt), *.txt", , , , False)'修改部分,TRUE为多选,FALSE为单选
If VarType(theSh) = vbBoolean Then
MsgBox "取消"
Else
MsgBox "有 " & UBound(theSh) & " 个文本将要被导入~"
End If
Range("C3").Value = theSh’修改部分
End Sub