在用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")  
     n = Len(sFile) - InStrRev(sFile, "\") 
     tt = Right(sFile, n) 
End Function

Join the Conversation

1 Comment

Leave a comment

Your email address will not be published. Required fields are marked *