以前做了几个VB连接Excel2003的小程序···前几天把Excel更新成2007后就 无法用VB打开了···VB连接03跟连接07的代码不一样??
Set xlApp = CreateObject("Excel.Application")
xlBook = xlApp.Workbooks.Open(App.Path + "\价格.xls")
Set xlSheet = xlBook.Worksheets("sheet1")
X = xlSheet.UsedRange.Columns.Count
l = xlSheet.UsedRange.Rows.Count
连接03的时候没问题··连接07就连不上了··
有知道的么?帮帮忙··谢谢··
xlBook = xlApp.Workbooks.Open(App.Path + "\价格.xls")
在这个地方就出错了````
vb 无法打开Excel2007
答案:2 悬赏:30 手机版
解决时间 2021-03-05 01:26
- 提问者网友:鐵馬踏冰河
- 2021-03-04 13:04
最佳答案
- 五星知识达人网友:枭雄戏美人
- 2021-03-04 13:32
应该是缺少了激活EXCEL的工作表.略改一下就行了.
Set xlApp = CreateObject("Excel.Application")
xlBook = xlApp.Workbooks.Open(App.Path + "\价格.xls")
Set xlSheet = xlBook.Worksheets(1)
xlsheet.Activate
X = xlSheet.UsedRange.Columns.Count
l = xlSheet.UsedRange.Rows.Count
Set xlApp = CreateObject("Excel.Application")
xlBook = xlApp.Workbooks.Open(App.Path + "\价格.xls")
Set xlSheet = xlBook.Worksheets(1)
xlsheet.Activate
X = xlSheet.UsedRange.Columns.Count
l = xlSheet.UsedRange.Rows.Count
全部回答
- 1楼网友:七十二街
- 2021-03-04 15:12
function unprotectxl(filepath,filename,pwd,writerespwd)
set objexcel=createobject("excel.application")
objexcel.visible=false
testdata=filepath&"\"&filename
set oworkbook=objexcel.workbooks
set mywkbook=objexcel.workbooks.open (testdata,0,false,5,pwd,writerespwd)
objexcel.displayalerts=false
oworkbook(filename).activate
for each w in objexcel.workbooks
w.saveas testdata,,"",""
next
objexcel.workbooks.close
objexcel.quit
set oworkbook=nothing
set objexcel=nothing
end function
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯