发布于 2011-10-13 13:57:08
12楼
全变成问号了,再发一下代码,帮我看下:
On Error Resume Next '此句必须有,防止无EXCEL进程时GetObject出错退出
Dim xlsname,xlapp,xlbook,xlsheet,isOpen,i,TagName,TagValue,Layer,Cur_row
xlsname="F:\Data.xls" 'Excel文档路径
Set xlapp=GetObject(,"Excel.Application") '获取当前运行的Excel应用程序对象
If Typename(xlapp)="Application" Then 'Excel已打开,遍历工作薄查找对应文档是否已打开
For Each xlbook In xlapp.Workbooks
If xlbook.FullName=xlsname Then
isOpen=True
Exit for
End if
Next
If Not isOpen Then '如果对应文档没打开则打开
Set xlbook=xlapp.Workbooks.Open(xlsname)
End if Else '当前没有打开Excel程序则创建Excel应用程序并打开对应的文档
Set xlapp=CreateObject("Excel.Application")
Set xlbook=xlapp.Workbooks.Open(xlsname)
End if
xlapp.visible =true '显示可见
set xlsheet =x1book.worksheets("sheet1")
for i=3 to xlsheet.range("A65536").end(3).row
i=i+1
x1sheet.cell(i,1).value=ScreenItems("wincc上输入输出域的名称”).outputvalue
next
最好的永远没有