Jump to content

Update the Excel UDF that comes with AutoIt


water
 Share

Recommended Posts

Do you have the Beta version installed in C:Program Files (x86)AutoIt3 or in C:Program Files (x86)AutoIt3Beta? Because if it's the latter, you're still running it with the production version.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Do you have the Beta version installed in C:Program Files (x86)AutoIt3 or in C:Program Files (x86)AutoIt3Beta? Because if it's the latter, you're still running it with the production version.

ill be damed. I thought it "replaced" the old version...

of course, when use the "run beta" command from the menu. Ot works. Sorry for the trouble :)

Link to comment
Share on other sites

Glad the problem could be solved and it wasn't caused by the UDF.

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

 

Link to comment
Share on other sites

  • 2 weeks later...

Does anyone have any insight into my problem?

I can save a workbook using "Global Const $xlOpenXMLWorkbook = 51 ; Open XML Workbook", but

cannot save a workbook using "Global Const $xlOpenXMLWorkbookMacroEnabled = 52 ; Open XML Workbook Macro Enabled"

I can import the macro into the workbook, but I cannot save it.  I have administrative privleges.  Any ideas?

Link to comment
Share on other sites

Can you please post the statement you use to save the workbook?

Do you know what the enumerations $xlOpenXMLWorkbook and $xlOpenXMLWorkbookMacroEnabled are used for?

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

 

Link to comment
Share on other sites

Can you please post the statement you use to save the workbook?

Do you know what the enumerations $xlOpenXMLWorkbook and $xlOpenXMLWorkbookMacroEnabled are used for?

 

I figured out what I was doing wrong:

This statement would cause the workbook not to be saved:

_Excel_BookSaveAs($oWorkbook, "C:temptemp.xlsx", $xlOpenXMLWorkbookMacroEnabled, True)

The file extension was incorrect.  It should be:

_Excel_BookSaveAs($oWorkbook, "C:temptemp.xlsm", $xlOpenXMLWorkbookMacroEnabled, True)

Link to comment
Share on other sites

Glad the problem could be solved and it wasn't caused by the UDF :)

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

 

Link to comment
Share on other sites

  • 2 weeks later...

Hey again!

I've run into a little trouble using the _Excel_RangeWrite function. I have a 2D array that is parsed from a CSV file which contains about 46,000 rows and 7 columns of data. When trying to import this into excel using the rangewrite function, it returns "$vRange.Value = $oExcel.Transpose($vValue)^ ERROR".

#include <Excel Rewrite.au3>
#include <CSV.au3>

consolewrite("Opening Excel..." & @CRLF)
$oExcel = _Excel_Open()
consolewrite("Creating Workbook..." & @CRLF)
$oWorkBook = _Excel_BookNew($oExcel, 1)
consolewrite("Adding Sheets..." & @CRLF)
_Excel_SheetAdd($oWorkbook, -1, False, 1, "Master List")
consolewrite("Deleting First Sheet..." & @CRLF)
_Excel_SheetDelete($oWorkbook, 1)
consolewrite("Parsing master..." & @CRLF)
$ArrMaster = _ParseCSV($SaveDirectory & "\Master.csv")
consolewrite("Writing Master to Excel..." & @CRLF)
_Excel_RangeWrite($oWorkbook, 1, $ArrMaster)

Opening the file directly in excel from the _Excel_BookOpenText function works perfectly, but I'm trying to combine multiple large CSV files into one excel book with multiple sheets. any help you could give would be GREATLY appreciated! thank you!

Link to comment
Share on other sites

Depending on the Excel version you use there is a limit of the number of elements the Excel transpose method can process. In this case set parameter $bForceFunc to True.

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

 

Link to comment
Share on other sites

Hi Water, thanks for the quick reply!

I've just tried this, but now I'm getting an unknown function name for _ArrayTranspose. I've double checked, but I don't see that I'm missing any required files. I've got ExcelConstants.au3 and Excel Rewrite.au3 both in my includes directory. is there another that I need?

Thanks again!

Link to comment
Share on other sites

You need to run the Excel rewrite with the latest AutoIt beta version.

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

 

Link to comment
Share on other sites

Thanks :)

If there is anything missing I would like to know ;)

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

 

Link to comment
Share on other sites

Released Beta 3 of the UDF.
For download and a history of changes please see post #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

 

Link to comment
Share on other sites

One more issue I'm running into: When I use the _Excel_BookOpenText function, it doesn't appear to be returning a valid workbook object. here is a simplified version of the code I'm using:

#include <Excel Rewrite.au3>

$CSVFileName = "C:\test.csv"
$XLSFileName = "C:\test.xls"

consolewrite("Opening Excel..." & @CRLF)
$oExcel = _Excel_Open(true)
$oWB = _Excel_BookOpenText($oExcel, $CSVFileName)
ConsoleWrite("_Excel_BookOpenText @Error: " & @Error & @CRLF)
ConsoleWrite("_Excel_BookOpenText @Extended: " & @Extended & @CRLF)
_Excel_BookSaveAs($oWB, $XLSFileName)
ConsoleWrite("_Excel_BookSaveAs @Error: " & @Error & @CRLF)
ConsoleWrite("_Excel_BookSaveAs @Extended: " & @Extended & @CRLF & @CRLF)

Running this extremely simple script produces the following output in the console:

Opening Excel...
_Excel_BookOpenText @Error: 0
_Excel_BookOpenText @Extended: 0
_Excel_BookSaveAs @Error: 1
_Excel_BookSaveAs @Extended: 0

and results in the file actually being successfully opened, so I'm sure that part works. any suggestions?

edit: and I did just update to beta 3, but it seems like the problem persists in beta 2 as well.
 

second edit: I was thinking as well... is there an option somewhere that I've missed to set column width and row height?

Edited by FlashpointBlack
Link to comment
Share on other sites

I will have a look.

BTW:

ConsoleWrite("_Excel_BookOpenText @Error: " & @Error & @CRLF)
ConsoleWrite("_Excel_BookOpenText @Extended: " & @Extended & @CRLF)

will always return 0 for the second line because the first ConsoleWrite resets @error and @extended

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

 

Link to comment
Share on other sites

I found the bug. Method OpenText doesn't return the Workbook object :mad:

Please replace the last line in function _Excel_BookOpenText

Return $oWorkbook

with

Return $oExcel.ActiveWorkbook ; Method OpenText doesn't return the Workbook object

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

 

Link to comment
Share on other sites

Thanks a lot!

I'm glad someone uses this UDF so bugs will be discovered and it can mature over time. Before it can replace the current UDF that come with AutoIt it should be as bug free as possible ;)

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

 

Link to comment
Share on other sites

second edit: I was thinking as well... is there an option somewhere that I've missed to set column width and row height?

No, you didn't miss this functions. This UDF has no formatting functions at the moment.

As most of the Excel formatting methods would lead to an AutoIt function with a single line I haven't implemented any of them.

If anyone can show me a sensible way to implement formatting functions I will be happy do add them.

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

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...