Jump to content

Excel Example Scripts


water
 Share

Recommended Posts

Attached you will find a few examples based on the Excel UDF. Enjoy!

Worksheet Change Event
This example handles the Excel Worksheet change event when a cell has been changed and sets the color of the cell to red.

Example Excel Events.zip

History:

Spoiler

2013-11-07: Added version 1.0.

 

Set color of every second row
This example sets the background color for every second row in the used range to yellow.

Example Color Rows.zip

History:

Spoiler

2013-11-22: Added version 1.0.

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

Nice example, thanks.

While it runs fine, if I run by pressing f5:

>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /prod /AU3Check /in "C:UsersLorenDesktopExcel Rewrite Beta 3Excel Rewrite.au3"
+>06:27:14 Starting AutoIt3Wrapper v.2.1.0.33    Environment(Language:0409  Keyboard:00000409  OS:WIN_7/Service Pack 1  CPU:X64 OS:X64)
>Running AU3Check (1.54.22.0)  from:C:Program Files (x86)AutoIt3
C:UsersLorenDesktopExcel Rewrite Beta 3Excel Rewrite.au3(169,56) : ERROR: ObjGet() [built-in] called with wrong number of args.
        $oWorkbook = ObjGet("", $sCLSID_Workbook, $iCount + 1)
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

Is this due to my current version being 3.3.8.1?

Link to comment
Share on other sites

Correct. To run the new Excel UDF you need 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

I am getting closer to some excel work using the new UDF so this will help

Ok that works  im curious can you add tabs using the new udf?

Nvm _Excel_SheetAdd

Thx

Edited by Chimaera
Link to comment
Share on other sites

Correct. To run the new Excel UDF you need the latest AutoIt beta version.

Cannot wait to try this out...if I get the UDF, do I need the beta version still?

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

Correct,

the new Excel UDF (and the examples) only run in combination with the latest AutoIt beta.

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

Correct. To run the new Excel UDF you need the latest AutoIt beta version.

Hi,

I have downloaded the latest beta Excel UDF & copied everything in the installation path of AutoIt.

But when I include Excel Rewrite.au3 in my script, I got below errors:

>Running AU3Check (1.54.22.0)  from:C:Program Files (x86)AutoIt3
C:Program Files (x86)AutoIt3IncludeExcelConstants.au3(29,40) : ERROR: $xlCenter previously declared as a 'Const'.
Global Const $xlCenter = -4108 ; Center
 
I wanted to try the latest UDF as I need to automatically find the range in my excel table.
Link to comment
Share on other sites

And you can't include the old and the new Excel UDF in the same script.

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

My rewritten UDF includes all Constants that are used by the UDF itself or which can be passed as parameters.

If the users script or another include has one of this constants defined as well then you get the above error message.

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

Example to set the background color of every second row in the used range added.

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

  • 1 month later...

Released Beta 4 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

  • 1 month later...

Just a basic script for noobs like me :D

#Include <Excel Rewrite.au3>


$prog_excel = _Excel_Open() ;opens a new instance of the Excel software

if $prog_excel == 0 then

   msgbox("","Error", "Unable to open MS Excel")

   exit

endif


$workbook = _Excel_BookOpen($prog_excel, "Path to file\Excel_file.xlsx") ; open an existing excel file

if $workbook == 0 then

   msgbox("","Error", "Unable to open the specified excel file")

   exit

endif


;read or write values


$read = _Excel_RangeRead($workbook, $workbook.Activesheet, "A1", 1) ; read the content of the A1 case of the excel file

_Excel_RangeWrite($workbook, $workbook.Activesheet, "TEST", "A1") ; write "TEST" in the A1 case of the excel file


; changing fonts / case styles


$prog_excel.Activesheet.range("A1").Font.ColorIndex = 3 ; set font color to red

$prog_excel.Activesheet.range("A1").Font.Bold = True ; set font to bold

$prog_excel.Activesheet.range("A1").HorizontalAlignment = -4108 ; center text in cell


;exit Excel

_Excel_Close($prog_excel) ; closes the instance of the Excel software
 
Edited by Neutro
Link to comment
Share on other sites

  • 3 weeks later...

Released Beta 5 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

  • 1 month later...

Hello Everyone,

How to change or apply background color for a cell(s) in a entire row or column ?

I tried font.background, which didn't worked.


Can anyone share an example for changing background color ?

K L M
------------------
Real Fakenamovich
------------------
K L M
------------------
Real Fakenamovich
------------------

Link to comment
Share on other sites

  • Moderators

See here for a quick and dirty.

One cell:

#include <Excel.au3>

$oExcel = _ExcelBookNew()
    $oExcel.Cells(1,2).Interior.ColorIndex = 44

Row:

#include <Excel.au3>

$oExcel = _ExcelBookNew()
    $oExcel.Cells(1,2).EntireRow.Interior.ColorIndex = 44

Column:

#include <Excel.au3>

$oExcel = _ExcelBookNew()
    $oExcel.Cells(1,2).EntireColumn.Interior.ColorIndex = 44

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Thanks JLogan3o13.

It Works.

I had tried this:-

;;;; Author: KLM

#include <Excel.au3>
#include <Array.au3>
#include <String.au3>

Func1()

Func Func1()

    Local $cols[5] = ["4", "No.", "Name", "Address", "Phone"]

    Local $data1[5] = ["4", "1", "Hello", "Somewhere", "1234567890"]

    Local $data2[5] = ["4", "2", "World", "Thereandhere", "9012345678"]

    Local $i, $j = 1

    $oExcel = _ExcelBookNew(1)  ;;;; 0 => Not Visible

    _ExcelColumnInsert($oExcel, 1, 4)

    $oExcel.ActiveSheet.Rows(1).RowHeight = 40 ;;;; Only For First Row

    For $i = 1 To $cols[0] Step 1

        _ExcelWriteCell($oExcel, $cols[$i], 1, $i)  ;;;; 1 => First Row

        _ExcelFontSetProperties1($oExcel, 1, $i, 1, $i, True, True, True)

        _ExcelHorizontalAlignSet($oExcel, 1, $i, 1, $i, "center")

        _ExcelVerticalAlignSet2($oExcel, 1, $i, 1, $i, "center")


        ;$oExcel.ActiveSheet.Rows($i).ColumnWidth = 40 ;;;; Also Works For All Rows

        $oExcel.ActiveSheet.Columns($i).ColumnWidth = 40

    Next

    CommonExcelWrites($oExcel, $data1, 2)

    CommonExcelWrites($oExcel, $data2, 3)

    MsgBox(-1, "", @error)

    _ExcelBookClose($oExcel)

EndFunc

Func CommonExcelWrites($oExcel, $data, $RowIndex)

    Local $i

    For $i = 1 To $data[0] Step 1

        _ExcelWriteCell($oExcel, $data[$i], $RowIndex, $i)  ;;;; 1 => First Row

        _ExcelFontSetProperties2($oExcel, $RowIndex, $i, $RowIndex, $i, False, False, False)

        _ExcelHorizontalAlignSet($oExcel, $RowIndex, $i, $RowIndex, $i, "center")

        ;$oExcel.ActiveSheet.Rows($i).ColumnWidth = 40 ;;;; Also Works For All Rows

        $oExcel.ActiveSheet.Columns($i).ColumnWidth = 40

    Next

EndFunc

Func _ExcelFontSetProperties1($oExcel, $sRangeOrRowStart, $iColStart = 1, $iRowEnd = 1, $iColEnd = 1, $fBold = False, $fItalic = False, $fUnderline = False)
    If Not IsObj($oExcel) Then Return SetError(1, 0, 0)
    If Not StringRegExp($sRangeOrRowStart, "[A-Z,a-z]", 0) Then
        If $sRangeOrRowStart < 1 Then Return SetError(2, 0, 0)
        If $iColStart < 1 Then Return SetError(2, 1, 0)
        If $iRowEnd < $sRangeOrRowStart Then Return SetError(3, 0, 0)
        If $iColEnd < $iColStart Then Return SetError(3, 1, 0)
        $oExcel.Activesheet.Range($oExcel.Cells($sRangeOrRowStart, $iColStart), $oExcel.Cells($iRowEnd, $iColEnd) ).Font.Name = "Tahoma"
        $oExcel.Activesheet.Range($oExcel.Cells($sRangeOrRowStart, $iColStart), $oExcel.Cells($iRowEnd, $iColEnd) ).Font.Size = 22 ;.Name = "Arial"
        $oExcel.Activesheet.Range($oExcel.Cells($sRangeOrRowStart, $iColStart), $oExcel.Cells($iRowEnd, $iColEnd) ).Font.Bold = $fBold
        $oExcel.Activesheet.Range($oExcel.Cells($sRangeOrRowStart, $iColStart), $oExcel.Cells($iRowEnd, $iColEnd) ).Font.Italic = $fItalic
        $oExcel.Activesheet.Range($oExcel.Cells($sRangeOrRowStart, $iColStart), $oExcel.Cells($iRowEnd, $iColEnd) ).Font.Underline = $fUnderline
        $oExcel.Activesheet.Range($oExcel.Cells($sRangeOrRowStart, $iColStart), $oExcel.Cells($iRowEnd, $iColEnd) ).Font.Color = 0xFFBC7A

        ;$oExcel.Activesheet.Range($oExcel.Cells($sRangeOrRowStart, $iColStart), $oExcel.Cells($iRowEnd, $iColEnd) ).Font.Background = 0xFFBC7A


        $oExcel.Activesheet.Range($oExcel.Cells($sRangeOrRowStart, $iColStart), $oExcel.Cells($iRowEnd, $iColEnd) ).Borders.Color = 0x000000
        $oExcel.Activesheet.Range($oExcel.Cells($sRangeOrRowStart, $iColStart), $oExcel.Cells($iRowEnd, $iColEnd) ).Borders.Value = 4 ;;;; ( < 14 )
        $oExcel.Activesheet.Range($oExcel.Cells($sRangeOrRowStart, $iColStart), $oExcel.Cells($iRowEnd, $iColEnd) ).Borders.Weight = 4

    Else
        $oExcel.Activesheet.Range($sRangeOrRowStart).Font.Name = "Tahoma"
        $oExcel.Activesheet.Range($sRangeOrRowStart).Font.Size = 22
        $oExcel.Activesheet.Range($sRangeOrRowStart).Font.Bold = $fBold
        $oExcel.Activesheet.Range($sRangeOrRowStart).Font.Italic = $fItalic
        $oExcel.Activesheet.Range($sRangeOrRowStart).Font.Underline = $fUnderline
        $oExcel.Activesheet.Range($sRangeOrRowStart).Font.Color = 0xFFBC7A


        $oExcel.Activesheet.Range($sRangeOrRowStart).Font.Borders.Color = 0x000000
        $oExcel.Activesheet.Range($sRangeOrRowStart).Font.Borders.Value = 4 ;;;; ( < 14 )
        $oExcel.Activesheet.Range($sRangeOrRowStart).Font.Borders.Weight = 4

    EndIf
    Return 1
EndFunc


Func _ExcelFontSetProperties2($oExcel, $sRangeOrRowStart, $iColStart = 1, $iRowEnd = 1, $iColEnd = 1, $fBold = False, $fItalic = False, $fUnderline = False)
    If Not IsObj($oExcel) Then Return SetError(1, 0, 0)
    If Not StringRegExp($sRangeOrRowStart, "[A-Z,a-z]", 0) Then
        If $sRangeOrRowStart < 1 Then Return SetError(2, 0, 0)
        If $iColStart < 1 Then Return SetError(2, 1, 0)
        If $iRowEnd < $sRangeOrRowStart Then Return SetError(3, 0, 0)
        If $iColEnd < $iColStart Then Return SetError(3, 1, 0)
        $oExcel.Activesheet.Range($oExcel.Cells($sRangeOrRowStart, $iColStart), $oExcel.Cells($iRowEnd, $iColEnd) ).Font.Name = "Tahoma"
        $oExcel.Activesheet.Range($oExcel.Cells($sRangeOrRowStart, $iColStart), $oExcel.Cells($iRowEnd, $iColEnd) ).Font.Size = 22 ;.Name = "Arial"
        $oExcel.Activesheet.Range($oExcel.Cells($sRangeOrRowStart, $iColStart), $oExcel.Cells($iRowEnd, $iColEnd) ).Font.Bold = $fBold
        $oExcel.Activesheet.Range($oExcel.Cells($sRangeOrRowStart, $iColStart), $oExcel.Cells($iRowEnd, $iColEnd) ).Font.Italic = $fItalic
        $oExcel.Activesheet.Range($oExcel.Cells($sRangeOrRowStart, $iColStart), $oExcel.Cells($iRowEnd, $iColEnd) ).Font.Underline = $fUnderline
        $oExcel.Activesheet.Range($oExcel.Cells($sRangeOrRowStart, $iColStart), $oExcel.Cells($iRowEnd, $iColEnd) ).Font.Color = 0x000000

        ;$oExcel.Activesheet.Range($oExcel.Cells($sRangeOrRowStart, $iColStart), $oExcel.Cells($iRowEnd, $iColEnd) ).Font.Background = 0xFFBC7A

        $oExcel.Activesheet.Range($oExcel.Cells($sRangeOrRowStart, $iColStart), $oExcel.Cells($iRowEnd, $iColEnd) ).Borders.Color = 0x000000
        $oExcel.Activesheet.Range($oExcel.Cells($sRangeOrRowStart, $iColStart), $oExcel.Cells($iRowEnd, $iColEnd) ).Borders.Value = 4 ;;;; ( < 14 )
        $oExcel.Activesheet.Range($oExcel.Cells($sRangeOrRowStart, $iColStart), $oExcel.Cells($iRowEnd, $iColEnd) ).Borders.Weight = 4

    Else
        $oExcel.Activesheet.Range($sRangeOrRowStart).Font.Name = "Tahoma"
        $oExcel.Activesheet.Range($sRangeOrRowStart).Font.Size = 22
        $oExcel.Activesheet.Range($sRangeOrRowStart).Font.Bold = $fBold
        $oExcel.Activesheet.Range($sRangeOrRowStart).Font.Italic = $fItalic
        $oExcel.Activesheet.Range($sRangeOrRowStart).Font.Underline = $fUnderline
        $oExcel.Activesheet.Range($sRangeOrRowStart).Font.Color = 0x000000


        $oExcel.Activesheet.Range($sRangeOrRowStart).Font.Borders.Color = 0x000000
        $oExcel.Activesheet.Range($sRangeOrRowStart).Font.Borders.Value = 4 ;;;; ( < 14 )
        $oExcel.Activesheet.Range($sRangeOrRowStart).Font.Borders.Weight = 4

    EndIf
    Return 1
EndFunc

Func _ExcelVerticalAlignSet2($oExcel, $sRangeOrRowStart, $iColStart = 1, $iRowEnd = 1, $iColEnd = 1, $sHorizAlign = "left")
    If Not IsObj($oExcel) Then Return SetError(1, 0, 0)
    If Not StringRegExp($sRangeOrRowStart, "[A-Z,a-z]", 0) Then
        If $sRangeOrRowStart < 1 Then Return SetError(2, 0, 0)
        If $iColStart < 1 Then Return SetError(2, 1, 0)
        If $iRowEnd < $sRangeOrRowStart Then Return SetError(3, 0, 0)
        If $iColEnd < $iColStart Then Return SetError(3, 1, 0)
        Switch ($sHorizAlign)
            Case "left"
                $oExcel.Activesheet.Range($oExcel.Cells($sRangeOrRowStart, $iColStart), $oExcel.Cells($iRowEnd, $iColEnd) ).VerticalAlignment = $xlLeft
            Case "center", "centre"
                $oExcel.Activesheet.Range($oExcel.Cells($sRangeOrRowStart, $iColStart), $oExcel.Cells($iRowEnd, $iColEnd) ).VerticalAlignment = $xlCenter
            Case "right"
                $oExcel.Activesheet.Range($oExcel.Cells($sRangeOrRowStart, $iColStart), $oExcel.Cells($iRowEnd, $iColEnd) ).VerticalAlignment = $xlRight
        EndSwitch
    Else
        Switch ($sHorizAlign)
            Case "left"
                $oExcel.Activesheet.Range($sRangeOrRowStart).VerticalAlignment = $xlLeft
            Case "center", "centre"
                $oExcel.Activesheet.Range($sRangeOrRowStart).VerticalAlignment = $xlCenter
            Case "right"
                $oExcel.Activesheet.Range($sRangeOrRowStart).VerticalAlignment = $xlRight
        EndSwitch
    EndIf
    Return 1
EndFunc   ;==>_ExcelVerticalAlignSet

K L M
------------------
Real Fakenamovich
------------------
K L M
------------------
Real Fakenamovich
------------------

Link to comment
Share on other sites

Could you please post such questions in the General Help and Support forum?

This is for Example scripts like I posted in post #1 AND they are for the rewritten Excel UDF that comes with the latest beta of AutoIt.

Thanks

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...