签到有奖
消息提醒
运维工程师专区
官方商城
扫码分享好友 任选多种周边
https://www.ad.siemens.com.cn/club/bbs/post.aspx?a_id=1266491&b_id=5&s_id=17&num=12#anch
根据上面这个简单修改的,在在编译时报Write变量未声明所以没有使用,
但是报“Set ObjExcelApp = Nothing”溢出,而在触摸屏里面运行时直接在
Set fso = CreateObject("scripting.FileSystemObject")这里就报错
Dim fso,myfile
Set fso = CreateObject("scripting.FileSystemObject")
Set myfile = fso.GetFile("\Storage Card USB\data.xls")
Dim ObjExcelApp
Set ObjExcelApp = CreateObject("Excel.Application")
'objExcelApp.Visible = True
ObjExcelApp.Workbooks.Open myfile
'上面的程序段是为了打开d盘excel文件
SmartTags("aa")=4
Dim aa_data
ObjExcelApp.worksheets ("sheet1").Cells(2, 9).VAlue = SmartTags("aa")
Dim i,j
If ObjExcelApp.worksheets ("sheet1").Cells(2, 9).VAlue>1.0 Then
i=2
j=6
End If
If ObjExcelApp.worksheets ("sheet1").Cells(2, 9).VAlue>0.8 And ObjExcelApp.worksheets ("sheet1").Cells(2, 9).VAlue<1.0 Then
i=7
j=11
If ObjExcelApp.worksheets ("sheet1").Cells(2, 9).VAlue>0.6 And ObjExcelApp.worksheets ("sheet1").Cells(2, 9).VAlue<0.8 Then
i=12
j=16
If ObjExcelApp.worksheets ("sheet1").Cells(2, 9).VAlue<0.6 Then
i=17
j=21
'判断数据保存位置
Do While i<j
ObjExcelApp.worksheets ("sheet1").Cells(i, 1).VAlue =ObjExcelApp.worksheets ("sheet1").Cells(i+1, 1).VAlue
ObjExcelApp.worksheets ("sheet1").Cells(i, 2).VAlue = ObjExcelApp.worksheets ("sheet1").Cells(i+1, 2).VAlue
i=i+1
Loop
ObjExcelApp.worksheets ("sheet1").Cells(i, 1).VAlue =SmartTags("yy")
ObjExcelApp.worksheets ("sheet1").Cells(i, 2).VAlue =SmartTags("xx")
'写数据到excel表格
ObjExcelApp.ActiveWorkbook.Save
'保存表格
Dim cons_data,ax1_data,ax2_data,ax3_data,ax4_data,ax5_data,ax6_data
Set cons_data=(SmartTags("cons"))
Set ax1_data=(SmartTags("ax1"))
Set ax2_data=SmartTags("ax2")
Set ax3_data=SmartTags("ax3")
Set ax4_data=SmartTags("ax4")
Set ax5_data=SmartTags("ax5")
Set ax6_data=SmartTags("ax6")
SmartTags("cons").Value = ObjExcelApp.worksheets ("sheet1").Cells(23,7).value
ax1_data.Value = ObjExcelApp.worksheets ("sheet1").Cells(23, 6).value
ax2_data.Value = ObjExcelApp.worksheets ("sheet1").Cells(23, 5).value
ax3_data.Value = ObjExcelApp.worksheets ("sheet1").Cells(23, 4).value
ax4_data.Value = ObjExcelApp.worksheets ("sheet1").Cells(23, 3).value
ax5_data.Value = ObjExcelApp.worksheets ("sheet1").Cells(23, 2).value
ax6_data.Value = ObjExcelApp.worksheets ("sheet1").Cells(23, 1).value
'上面的作用是将Excel表格中的数据读到wincc,存到临时变量里面
ObjExcelApp.Workbooks.Close
ObjExcelApp.Quit
Set ObjExcelApp = Nothing
'到这里为止,关闭刚才打开的excel程序了
SetTag SmartTags("cons"),cons_data.Value
SetTag SmartTags("ax1"),ax1_data.Value
SetTag SmartTags("ax2"),ax2_data.Value
SetTag SmartTags("ax3"),ax3_data.Value
SetTag SmartTags("ax4"),ax4_data.Value
SetTag SmartTags("ax5"),ax5_data.Value
SetTag SmartTags("ax6"),ax6_data.Value
'cons_data.Write
'ax1_data.Write
'ax2_data.Write
'ax3_data.Write
'ax4_data.Write
'ax5_data.Write
'ax6_data.Write 这些在编译时报Write变量未声明所以没有使用
'最后是把读到的excel值从临时变量中写入它对应的wincc变量中
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
帖子链接:https://www.ad.siemens.com.cn/club/bbs/post.aspx?a_id=1695513&b_id=5&s_id=0&num=3
在触摸屏上运行的?
应该是触摸屏不支持这个对象
我这里已经添加了这个,同时触摸屏里面的windows ce里面也显示了,然后用这个
Set oExcel = CreateObject("Excel.Application")
我询问了一下,windows ce不支持excel这个对象,哭了。。。。
那么只能用csv这个文件了
windows ce不支持excel
分享
扫码分享好友 任选多种好礼
收藏
有帮助
欢迎您访问支持中心!
丰富的视频,全方位的文档,大量的网友交流精华……
为了更好的完善这些内容,我们诚邀您在浏览结束后,花20秒左右的时间,完成一个用户在线调查!
感谢您的支持!
密码至少8位,包含大、小写字母,数字和符号至少三种。
允许邮箱和手机接收来自支持中心网站的信息
我已同意《支持中心网站注册协议和隐私政策》
微信登录扫码一键登录
验证码登录
密码登录
二维码失效点击重试
打开微信扫一扫,快速登录/注册
未注册手机验证后自动登录,注册即代表同意《支持中心网站注册协议和隐私政策》
三日内免验证登录
短信登录
登录