在用excel做文件导入时发现,一旦使用Commond Dialogs 就会出错
“The control could not be created because it is not properly licensed”
原因是,Commond Dialogs are not licensed to be used in Excel。经过搜索发现,其实VBA还有其它的法子获得文件路径。
Private Function OpenDialog() As String
Dim sFile As String
Dim n As Integer
'获取路径
sFile = Application.GetOpenFilename("MS excel (*.xls), *.xls")
'获取文件title的长度
n = Len(sFile) - InStrRev(sFile, "\")
'获得文件title
tt = Right(sFile, n)
End Function