JohnOne Posted February 21, 2015 Posted February 21, 2015 I have never had Excel on my computer and never used it at all, and I have a few questions. Can I manipulate excel files without opening visually an excel window? What my goal is, is to convert a plain txt .csv file to excel .xls. I seen a few examples with what looks like a depreciated function _ExcelWriteArray (or something similar to that name), is there a newer function similar to it? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Geir1983 Posted February 21, 2015 Posted February 21, 2015 First param of _Excel_Open is $visible Check out _Excel_RangeWrite to write arrays- JohnOne 1
water Posted February 21, 2015 Posted February 21, 2015 All functions of the latest Excel UDF start with _Excel_ (note the second underscore). User _Excel_BookOpen to open and import the CSV file to Excel. JohnOne 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
JohnOne Posted February 21, 2015 Author Posted February 21, 2015 Thanks, will do. but I found I can just open the csv file. I have this code... $oExcel1 = _Excel_Open() $oWorkbook = _Excel_BookOpen($oExcel1, "output.csv") Sleep(10000) _Excel_BookClose($oWorkbook, True) _Excel_Close($oExcel1) So looking to widen a row, as it only shows "########" and save it as .xls. Also _Excel_Close($oExcel1) does not close the instance of excel. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
JohnOne Posted February 21, 2015 Author Posted February 21, 2015 $oExcel1 = _Excel_Open() $oWorkbook = _Excel_BookOpen($oExcel1, "output.csv") Sleep(1000) _Excel_BookSaveAs($oWorkbook, "output.xls", $xlExcel8) _Excel_BookClose($oWorkbook, True) _Excel_Close($oExcel1) Think that's about it, the width of the column is okay when it's opened as .xls. But Excel still not closing. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Solution water Posted February 21, 2015 Solution Posted February 21, 2015 You need to widen the column when "####" is being shown. Use: $oExcel1.ActiveSheet.UsedRange.Columns.AutoFit = True so widen all columns in the used range. JohnOne 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
water Posted February 21, 2015 Posted February 21, 2015 But Excel still not closing. Was Excel already running when you started the script? JohnOne 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
JohnOne Posted February 21, 2015 Author Posted February 21, 2015 No, I tried again made sure no instances are running. It's from office 2013. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
water Posted February 21, 2015 Posted February 21, 2015 What are the return codes and values of @error and @extended after calling _Excel_BookClose and _Excel_Close? JohnOne 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
JohnOne Posted February 21, 2015 Author Posted February 21, 2015 $oExcel1 = _Excel_Open() ConsoleWrite("_Excel_Open " & @error & " " & @extended & @LF) $oWorkbook = _Excel_BookOpen($oExcel1, "output.csv") ConsoleWrite("_Excel_BookOpen " & @error & " " & @extended & @LF) ;$oExcel1.ActiveSheet.UsedRange.Columns.AutoFit = True Sleep(10000) _Excel_BookSaveAs($oWorkbook, @ScriptDir & "\output.xls", $xlExcel8) ConsoleWrite("_Excel_BookSaveAs " & @error & " " & @extended & @LF) _Excel_BookClose($oWorkbook, True) ConsoleWrite("_Excel_BookClose " & @error & " " & @extended & @LF) _Excel_Close($oExcel1) ConsoleWrite("_Excel_Close " & @error & " " & @extended & @LF) ShellExecute("output.xls") _Excel_Open 0 1 _Excel_BookOpen 3 -2147352567 _Excel_BookSaveAs 1 0 _Excel_BookClose 1 0 _Excel_Close 0 0 AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
JohnOne Posted February 21, 2015 Author Posted February 21, 2015 (edited) Sorry, once I put full path "$oWorkbook = _Excel_BookOpen($oExcel1, @ScriptDir & "output.csv")" it began to work. I swear it worked first couple of times without, perhaps working dir got changed somehow. EDIT: Also Excel is closing now too. Thank you muchly for help. Edited February 21, 2015 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
water Posted February 21, 2015 Posted February 21, 2015 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
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