| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1282 人关注过本帖
标题:实时错误‘91’ 对象变量或with块变量未设置
只看楼主 加入收藏
VBhere
Rank: 2
等 级:论坛游民
帖 子:21
专家分:19
注 册:2010-3-9
结帖率:100%
收藏
已结贴  问题点数:10 回复次数:1 
实时错误‘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

请问应该怎么解决这个问题?
搜索更多相关主题的帖子: 对象 实时 变量 
2010-03-09 16:38
bczgvip
Rank: 14Rank: 14Rank: 14Rank: 14
等 级:贵宾
威 望:66
帖 子:1310
专家分:5312
注 册:2009-2-26
收藏
得分:10 
程序代码:
Dim spShell As Object ' Shell
Dim spFolder As Object 'Folder
Dim spFolderitem As Object '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, "")
If spFolder Is Nothing Then
Else
    Set spFolderitem = spFolder.Self
    spPath = spFolderitem.Path
    spPath = Replace(spPath, "\", "\")
    Debug.Print spPath
End If
2010-03-10 20:43
快速回复:实时错误‘91’ 对象变量或with块变量未设置
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015706 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved