本帖最后由 CCM 于 2012-7-12 11:52 编辑
谢谢大家的帮忙,目前已经完成了。
後来与同事讨论,按照我们的作业程序调整如下:
#include <array.au3>
#include <Excel.au3>
#include <file.au3>
HotKeySet("^c", "MyExit");设定中断热键
Local $var = FileOpenDialog("请选择要开启的档案", "c:\data", " TXT(*.txt) ")
Local $file = FileOpen($var)
$oExcel = _ExcelBookNew()
$line = FileRead($file)
$str = StringRegExp($line, ".+PCL\h+6.+", 3)
$prt = UBound($str) - 2
Local $i = 0
While $i <= $prt
$name = StringRegExp($str[$i], '\d\.\h*(.+)\h*\(\w+\),\h*(.+)', 3)
$name[0] = _ExcelWriteCell($oExcel, $name[0], $i + 1, 1)
$name[1] = _ExcelWriteCell($oExcel, $name[1], $i + 1, 2)
$i = $i + 1
WEnd
_ArrayDisplay($str, "请核对表机信息")
If UBound($str) = 1 Then
MsgBox(0, "注意", "无法新增打印机信息,请手动处理。")
EndIf
_ExcelBookSaveAs($oExcel, "c:\data\filename", "xls", 0)
If Not @error Then MsgBox(0, "打印机新增成功", "档案存盘完毕,请按确定结束。", 5)
_ExcelBookClose($oExcel, 1, 0)
Func MyExit();接续中断热键
Exit
EndFunc ;==>MyExit
|