Me.CommonDialog1.CancelError = True
CommonDialog1.Filter = "(Excel)*.xls,*.xlsx|*.xls;*.xlsx"
Me.CommonDialog1.ShowOpen
sfn = Me.CommonDialog1.FileName
Text1.Text = sfn
If Err = cdlCancel Then
Exit Sub
End If'判断文件是否已经打开
Dim excelApp As Object
shortName = fs.GetFileName(sfn)
Me.CommonDialog1.CancelError = True
CommonDialog1.Filter = "(Excel)*.xls,*.xlsx|*.xls;*.xlsx"
Me.CommonDialog1.ShowOpen
sfn = Me.CommonDialog1.FileName
Text1.Text = sfn
If Err = cdlCancel Then
Exit Sub
End If'判断文件是否已经打开
Dim excelApp As Object
shortName = fs.GetFileName(sfn)
Set excelApp = GetObject(, "Excel.Application")
If Err Then
程序运行Set excelApp = GetObject(, "Excel.Application")就提示错误“activex component can‘t create object”
究竟是什么原因呢?请高手指点。
我的目的是想在打开文件前判断一下文件是否已经打开。
CommonDialog1.Filter = "(Excel)*.xls,*.xlsx|*.xls;*.xlsx"
Me.CommonDialog1.ShowOpen
sfn = Me.CommonDialog1.FileName
Text1.Text = sfn
If Err = cdlCancel Then
Exit Sub
End If'判断文件是否已经打开
Dim excelApp As Object
shortName = fs.GetFileName(sfn)
Me.CommonDialog1.CancelError = True
CommonDialog1.Filter = "(Excel)*.xls,*.xlsx|*.xls;*.xlsx"
Me.CommonDialog1.ShowOpen
sfn = Me.CommonDialog1.FileName
Text1.Text = sfn
If Err = cdlCancel Then
Exit Sub
End If'判断文件是否已经打开
Dim excelApp As Object
shortName = fs.GetFileName(sfn)
Set excelApp = GetObject(, "Excel.Application")
If Err Then
程序运行Set excelApp = GetObject(, "Excel.Application")就提示错误“activex component can‘t create object”
究竟是什么原因呢?请高手指点。
我的目的是想在打开文件前判断一下文件是否已经打开。
解决方案 »
- 求一段vb代码,望高手赐教!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- vb 关于删除相同字符
- 如何提高存储到access的速度
- 请问如何提取EXE文件的图标并保存起来?
- 如何将access中备注型字段中存储的rtf格式数据写入word文件中
- 用webbrowers取得框架网页中其中一个框架的html源代码
- 请问如何用VB连接读取网站上的数据库?
- VB数据库的问题
- 一个ActiveXDll注册时的问题,我挺奇怪,高手能告诉我吗?
- jinesc兄弟,只有你能帮我了!
- ActiveReports || Error 5000 : Error in processing report. [ Extended Info:用户 'sa' 登录失败。]
- VB6.0打开从SourceSafe上Get下来的工程时不提示SourceSafe登陆问题。
*****************************************************************************
欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码) http://www.cnblogs.com/feiyun0112/archive/2006/09/20/509783.html
Dim excelApp As Object
on error resume next
Set excelApp = GetObject(, "Excel.Application") '先取已存在的Excel实例
on error goto 0
if excelApp is nothing then
Set excelApp = CreateObject( "Excel.Application") '没有就新开一个
end if
dim xlBook as object
on error resume next
set xlBook = GetObject("C:\Book1.xls", "Excel.Application")
on error goto 0
if xlBook is nothing then
msgbox "文件未打开"
else
msgbox "文件已打开"
end if
Dim excelApp As Object
shortName = fs.GetFileName(sfn)
Set excelApp = GetObject(, "Excel.Application")
If Err Then
程序运行Set excelApp = GetObject(, "Excel.Application")就提示错误“activex component can‘t create object”
在这个函数的开始部分,加上 on error resume next,程序应该可以正常运行