LAMBERT99 Posted April 6, 2012 Share Posted April 6, 2012 I converted htm file to excel with the following script. and it gone well . ( as below Now , I want to convert a bunch of files in the script directory at once , is there a way to process n autoit or excel udf . i Am a new to autoit just one hour ......guide lines ...please ??? #include <Excel.au3> $sFilePath1 = @ScriptDir & "\CONRADS.htm" ;This file should already exist $oExcel = _ExcelBookOpen($sFilePath1) ;Show any errors that might occur when Opening the File If @error = 1 Then MsgBox(0, "Error!", "Unable to Create the Excel Object") Exit ElseIf @error = 2 Then MsgBox(0, "Error!", "File does not exist - Shame on you!") Exit EndIf _ExcelBookSaveAs($oExcel, @ScriptDir & "\CONRADS", "xls") If Not @error Then MsgBox(0, "Success", "File was Saved!", 3) _ExcelBookClose($oExcel, 1, 0) ;This method will save then Close the file, without any of the normal prompts, regardless of changes Link to comment Share on other sites More sharing options...
Zedna Posted April 6, 2012 Share Posted April 6, 2012 Look here at nice simple example for that: Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Zedna Posted April 6, 2012 Share Posted April 6, 2012 (edited) Something like this (not tested): #include <Excel.au3> #include <File.au3> #include <Array.au3> Local $FileList = _FileListToArray(@ScriptDir, '*.htm', 1) If @error Then MsgBox(0, "", "No Filess Found.") Exit EndIf ;~ _ArrayDisplay($FileList, "$FileList") For $i = 1 To $FileList[0] ConsoleWrite($FileList[$i] & @CRLF) ProcessFile($FileList[$i]) Next Func ProcessFile($file_name_htm) $file_name_htm = @ScriptDir & '' & $file_name_htm $file_name_xls = StringReplace($file_name_htm,'.htm','.xls') $oExcel = _ExcelBookOpen($file_name_htm) ;Show any errors that might occur when Opening the File If @error = 1 Then MsgBox(0, "Error!", "Unable to Create the Excel Object" & @CRLF & $file_name_htm) Exit ElseIf @error = 2 Then MsgBox(0, "Error!", "File does not exist - Shame on you!" & @CRLF & $file_name_htm) Exit EndIf _ExcelBookSaveAs($oExcel, $file_name_xls, "xls") If Not @error Then ConsoleWrite("Success - File was Saved!" & $file_name_xls & @CRLF) _ExcelBookClose($oExcel, 1, 0) ;This method will save then Close the file, without any of the normal prompts, regardless of changesEndFunc EndFunc Edited April 6, 2012 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
LAMBERT99 Posted April 7, 2012 Author Share Posted April 7, 2012 Thank you ! it works Like a charm !!! but this function works if only execel installed . Is there a way to run this with out EXECEL and quitely ????? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now