Jump to content

Update the Excel UDF that comes with AutoIt


water
 Share

Recommended Posts

Unfortunately I have no Office 2013 available, so can't test. Just Office 2010.
Maybe on MSDN there is a list. Will check ...

Edited by water

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 just scanned this thread. Can't find a problem with 2013.

Which function are you talking about?

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 haven't tried it at all as I haven't yet purchased it. I noticed in your OP, it says to test with 2003/2007, and I was just wondering if that meant that there were incapatibilities with 2013. If there aren't any known, I'll update! Thanks!

Edited by FlashpointBlack
Link to comment
Share on other sites

Just wanted that users with older Office versions and hence older file formats should test. I can't as I have only Office 2010 to play with.

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...

Hi water,

Hope you can advise me on this. I use to be able to use _ExcelSheetNameGet and _ExcelSheetNameSet from the older Excel UDF to search the excel sheet for some specific name and then do a rename but with the newer Excel Rewrite UDF, I can't seem to be able to do that as those two command are no longer in use. Any advise or example? TIA.

Link to comment
Share on other sites

_ExcelSheetNameGet is one statement:

$sName = $oExcel.ActiveSheet.Name
_ExcelSheetNameSet is one statement:
$oExcel.ActiveSheet.Name = $sName
That's the reason why the functions have been dropped. A single line doesn't need to be wrapped in a function.

Users need to be familiar with the Excel COM a bit.

Edited by water

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 information above.

Btw, I'm not sure if I'm the only one experiencing this bug but can you try this out and see if your excel workbook is corrupted after running this code?

First create a workbook with the filename 1.xlsx and then save and encrypt the workbook with a password. (I use password "1" in the example below.) After running the code below, the excel workbook seems to be corrupted. I can't see anything when I open the workbook using excel. The worksheets seems to have been deleted. Btw I'm using Office 2010 and Windows 7. 

PS: I have tried running with and without encrypted workbook and the results is the same. Corrupted workbook.

Opt("TrayIconHide", 1)
#include <GuiListView.au3>
#include <Array.au3>
#include <Timers.au3>
#include <Misc.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiButton.au3>
#include <DateTimeConstants.au3>
#include <Excel Rewrite.au3>
#include <ExcelConstants.au3>
#include <Constants.au3>

Global $sFilePath = @ScriptDir & "\1.xlsx"

If FileExists($sFilePath) Then
   Local $oAppl = _Excel_Open(False,Default,False,Default,Default)
   Local $oExcel = _Excel_BookOpen($oAppl,$sFilePath,Default,False,"1",Default)
   Local $aArray = _Excel_SheetList($oExcel)
   _Excel_BookClose($oExcel, True)
   _Excel_Close($oAppl, True, False)
   Exit
EndIf
Edited by lolipop
Link to comment
Share on other sites

Can't test at the moment, but I see no obvious error.

_Excel_BookClose or _Excel_Close shouldn't save the Workbook because nothing has been changed.

Can you check the file date/time of the Excel file in Windows Explorer after you have run the script?

The values of @error after each function call would be good to know as well.

I will test as soon as I find some spare time the next few days.

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't test at the moment, but I see no obvious error.

_Excel_BookClose or _Excel_Close shouldn't save the Workbook because nothing has been changed.

Can you check the file date/time of the Excel file in Windows Explorer after you have run the script?

The values of @error after each function call would be good to know as well.

I will test as soon as I find some spare time the next few days.

After running the script, the excel workbook modified date/time is changed. It seems to be saving the workbook. The value of @error is 0 for both the bookclose and close function.

Link to comment
Share on other sites

The problem is caused by you setting the Workbook to invisible.

This setting is then stored when the Workbook is being closed and saved.

You either need to set the workbook to visible bevore saving or after the workbook is being opened again.

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

The problem is caused by you setting the Workbook to invisible.

This setting is then stored when the Workbook is being closed and saved.

You either need to set the workbook to visible bevore saving or after the workbook is being opened again.

Noted. Thanks...I was trying out and was about to inform you of the same finding. One question, when I try setting the workbook to be visible and exit(auto save changes) The workbook doesn't unhide itself. It seems the changes are saved when hiding(invisible)  but not when I tried to unhide them.

Link to comment
Share on other sites

Seems to be an Excel thingy then.

Edited by water

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

Seems to be an Excel thingy then.

No, it doesn't seems to be excel error.

When I use the $oExcel = _Excel_BookOpen($oAppl,$sFilePath,Default,False,"1",Default), the excel workbook is hidden so that's the correct behaviour. But if I were to use this $oExcel = _Excel_BookOpen($oAppl,$sFilePath,Default,True,"1",Default) on a already hidden workbook, it doesn't seems to unhide the workbook. Doesn't that seems to be a problem?

PS: I can hide and unhide properly using excel but I can't unhide the workbook via the function.

 

Edited by lolipop
Link to comment
Share on other sites

You could change line

If Not $bVisible Then $oExcel.Activewindow.Visible = False

in function _Excel_BookOpen to

$oExcel.Activewindow.Visible = $bVisible

Setting the workbook to invisible only makes sense when _Excel_Open attaches to an already running and visible instance of Excel.

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 water. but it doesn't seems to work. I have try changing the excel_rewrite.au3 from the excel_bookopen function

If Not $bVisible Then $oExcel.Activewindow.Visible = False

to

If Not $bVisible Then $oExcel.Activewindow.Visible = $bVisible

the hidden workbook is still hidden when I use

Local $oAppl = _Excel_Open(True,Default,False,Default,Default)
Local $oExcel = _Excel_BookOpen($oAppl,$sFilePath,Default,True,"1",Default)

water, on 10 Feb 2014 - 11:41 PM, said: 

Setting the workbook to invisible only makes sense when _Excel_Open attaches to an already running and visible instance of Excel.

 I agree on this. but the case now is even if I was to use excel_open in visible instance together with excel_bookopen in visible instance on a already hidden workbook the workbook doesn't unhide itself. Therefore I thought this is a bug which I could report to you since I don't think it make sense that the UDF can hide a workbook but unable to unhide a workbook properly. If you think this is not a bug then by all means just ignore this. thanks. :)

Edited by lolipop
Link to comment
Share on other sites

Does the code I posted above work (without the If par)?

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

This works. Replace line

If Not $bVisible Then $oExcel.Activewindow.Visible = False

with

$oExcel.Windows($oWorkBook.Name).Visible = $bVisible

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...