实时错误‘91’ 对象变量或with块变量未设置
点击“确定”没问题,点击“取消”就出现错误——“实时错误‘91’ 对象变量或with块变量未设置”
代码如下:
Private Sub Command1_Click()
Dim spShell As New Shell
Dim spFolder As Folder
Dim spFolderitem As New ShellFolderItem
Dim spPath As String
Const WINDOW_HANDLE = 0
Const NO_OPTIONS = 0
Set spShell = CreateObject("Shell.Application")
Set spFolder = spShell.BrowseForFolder(WINDOW_HANDLE, "选择目录:", NO_OPTIONS, "")
Set spFolderitem = spFolder.Self
spPath = spFolderitem.Path
spPath = Replace(spPath, "\", "\")
Text4.Text = spPath
End Sub
请问应该怎么解决这个问题?