乔山办公网我们一直在努力
您的位置:乔山办公网 > excel表格制作 > VBA在EXCEL中调用excel的数据 编译错误:方法和数...

VBA在EXCEL中调用excel的数据 编译错误:方法和数...

作者:乔山办公网日期:

返回目录:excel表格制作


这是在EXCEL环境中直接引用EXCEL的语句。
在WORD中不能这样引用
代码如下:
Private Sub CommandButton1_Click()
Dim xls As New Excel.Application
Dim wk As New Excel.Workbook
Dim sh As New Excel.Worksheet
Set wk = xls.Workbooks.Open("d:\111.xls")
Set sh = wk.Sheets("Sheet1")
temp = sh.Range("A10")
Set sh = Nothing
wk.Close
Set wk = Nothing

xls.Quit
Set xls = Nothing

MsgBox temp

End Sub

不知道是哪句出错,不过,楼主确定每个UserForm中都有名为Label2的标签吗?
某些配置的数据丢失了

你xh没有声明变量啊,系统肯定不知道xh是什么东西,xh到底是数据还是对象啊,open方法你看帮助,不是哪里都能用的。

相关阅读

关键词不能为空
极力推荐

ppt怎么做_excel表格制作_office365_word文档_365办公网