Jump to content

Recommended Posts

Posted

Hi Experts,

 

May i seek your help if someone knows What is the Equivalent of Excel's VBA Clean Function in Autoit?

application.worksheetfunction.clean(text) ------- VBA

AutoIT---- ? 

Posted

Functions you can call from VBA can be called from AutoIt (using COM) as well.
Untested:

#include <Excel.au3>
Global $oExcel = _Excel_Open()
Global $sCleanString = $oExcel.WorksheetFunction.Clean("StringToBeCleaned")

 

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

 

Posted

Hi Water,

 

Thank you for the answer.

Will below code work?

#include <Excel.au3>
Global $oExcel = _Excel_Open()

$oWorkbook1 = _Excel_BookOpen($oExcel, @ScriptDir & "\Test.xlsx" , false, True)

$LastRow_test = $oWorkbook1.ActiveSheet.Range("A1").SpecialCells($xlCellTypeLastCell).Row

For $i = 1 to $LastRow_test step 1

    Global $sCleanString = $oExcel.WorksheetFunction.Clean("A" & $i)     ; ("StringToBeCleaned")

Next

 

Posted

Really only one way to find out, lol :D

You really shouldn't declare variables inside of a loop like that though. You're overwriting it each time the loop executes as well, so only the last string will be picked up

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Posted (edited)

I don't think so. According to the docu you need to pass the value of a cell to the Clean function.
Untested:

$sCleanString = $oExcel.WorksheetFunction.Clean($oExcel.ActiveSheet.Range("A" & $i).Value)     ; ("StringToBeCleaned")

 

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

 

Posted

Hi Water,

Thank you very much on your correction. I really appreciate it. I will try it now and will give updates.

Cheers to AutoIt Wizards! :)

 

 

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
×
×
  • Create New...