本帖最后由 heroxianf 于 2016-4-18 15:08 编辑
KK兄 我怎么换了个函数,打开就要提示错误呢?
之前用老版本EXCELUDF打开操作没问题的。_ExcelBookOpen($aWorkbook, $aFileName) ;打開EXCEL表
;~ $aWorkbook = ObjCreate("Excel.Application")
With $aWorkbook.worksheets("") ;ActiveSheet;
Func liulan()
$liulan = FileOpenDialog("浏览EXCEL格式", "", "EXCEL2007以下格式(*.xls)|EXCEL2010格式(*.xlsx)", 1)
If FileExists($liulan) Then
GUICtrlSetData($Input1, $liulan)
$aFileName = GUICtrlRead($Input1)
EndIf
_Excel_BookOpen($aWorkbook, $aFileName) ;打開EXCEL表
;~ $aWorkbook = ObjCreate("Excel.Application")
With $aWorkbook.worksheets("") ;ActiveSheet;
$ProdArray = .range("A1").currentregion.value
;下面這段為 尋找跟替換 ;檢查 讀取到的檔案是否 有 不應該出現的字
For $n = 0 To UBound($ProdArray) - 1
For $i = 0 To UBound($ProdArray, 2) - 1
$ProdArray[$n][$i] = StringReplace($ProdArray[$n][$i], "'", "")
Next
Next
EndWith
;~ MsgBox(0, "", UBound($ProdArray, 2))
ControlSetText($Form1, "", $Label2, UBound($ProdArray))
ControlSetText($Form1, "", $label4, UBound($ProdArray, 2) - 1)
MsgBox(0, "", $ProdArray[3][$i])
_Excel_BookNew($bWorkbook)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookNew Example 1", "Error creating new workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
GUICtrlSetState($Button_kaishi, 64)
EndFunc ;==>liulan
|