Jump to content

Use AutoIT to open a file in Microsoft TEAMS


Recommended Posts

Yes you can do anything.  You have a COM Excel object.  Everything that has been developed by MicroSoft is then available.  Google your request, you will get plenty of examples.

Link to comment
Share on other sites

On 5/7/2020 at 8:42 PM, Nine said:

Yes you can do anything.  You have a COM Excel object.  Everything that has been developed by MicroSoft is then available.  Google your request, you will get plenty of examples.

I'm sorry, I tried but I can't find what I look for. 

I have seen how to change a color, but not how to pick it and to compare.

😟

Yours sincerely

Kenneth.

Link to comment
Share on other sites

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

5 hours ago, water said:

Thank you @water

I know it might seems easy, but I can't figure it out. Sorry for that.

But I tried this and I just get an error in the msgbox.

#include <Excel.au3>
#include <MsgBoxConstants.au3>

; Create application object
Local $oExcel = _Excel_Open()
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookOpen Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

; Open an existing workbook and return its object identifier.
Local $sWorkbook = "C:\Users\DKSOKVK\OneDrive\Documents\Schedule Service Desk 2020.xlsx"
Local $oWorkbook = _Excel_BookOpenEx($oExcel, $sWorkbook)
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookOpen Example 1", "Error opening '" & $sWorkbook & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
;MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookOpen Example 1", "Workbook '" & $sWorkbook & "' has been opened successfully." & @CRLF & @CRLF & "Creation Date: " & $oWorkbook.BuiltinDocumentProperties("Creation Date").Value)

MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookOpen", $oExcel.ActiveWorkbook.Sheets(1).activeCell.Interior.Color)

 

Yours sincerely

Kenneth.

Link to comment
Share on other sites

Excel provides COM as an API to Excel functionality to be used by programs/scripts. The alternative is the GUI.
The Excel UDF is a wrapper around heavily used functions. It doesn't cover everything Excei provides. If you need more you can easily use COM in your scripts.

Maybe I'm going to translate the example I linked to above to AutoIt and post the script in the example scripts forum ;)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

Quick and dirty:

#include <Excel.au3>

; Reference: https://www.rapidtables.com/convert/color/rgb-to-hex.html
; Cell A1 background as RGB = 64, 128, 192 returns the following results:
; 64,128,192
; 0x4080C0
; 42
; 12615744

Global $oExcel = _Excel_Open()
Global $oWorkbook = _Excel_BookOpen($oExcel, "C:\Local\Test.xlsx")
ConsoleWrite(_Excel_BackgroundColorGet($oExcel.ActiveSheet.Range("A1"), "RGB") & @CRLF) ; RGB
ConsoleWrite(_Excel_BackgroundColorGet($oExcel.ActiveSheet.Range("A1"), "Hex") & @CRLF) ; HEX
ConsoleWrite(_Excel_BackgroundColorGet($oExcel.ActiveSheet.Range("A1"), "IDX") & @CRLF) ; IDX
ConsoleWrite(_Excel_BackgroundColorGet($oExcel.ActiveSheet.Range("A1")) & @CRLF) ; Decimal color value

Func _Excel_BackgroundColorGet($oRange, $sFormat = Default)
    ; formatType: Hex for 0xRRGGBB, RGB for (R,G,B) and IDX for VBA Color Index, Default for the decimal value
    $iColorValue = $oRange.DisplayFormat.Interior.Color
    Local $vColor
    Switch $sFormat
        Case "HEX"
            $vColor = "0x" & StringLeft(Hex(Mod($iColorValue, 256)), 2) & _
                    Hex(Mod(Int($iColorValue / 256), 256), 2) & _
                    Hex(Int($iColorValue / 65536), 2)
        Case "RGB"
            $vColor = Mod($iColorValue, 256) & "," & _
                    Mod(Int($iColorValue / 256), 256) & "," & _
                    Int($iColorValue / 65536)
        Case "IDX"
            $vColor = $oRange.Interior.ColorIndex
        Case Else
            $vColor = $iColorValue
    EndSwitch
    Return $vColor
EndFunc   ;==>_Excel_BackgroundColorGet

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

At least we come to an end ;)
If the function works I will add it as an example for others :)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

56 minutes ago, water said:

Quick and dirty:

#include <Excel.au3>

; Reference: https://www.rapidtables.com/convert/color/rgb-to-hex.html
; Cell A1 background as RGB = 64, 128, 192 returns the following results:
; 64,128,192
; 0x4080C0
; 42
; 12615744

Global $oExcel = _Excel_Open()
Global $oWorkbook = _Excel_BookOpen($oExcel, "C:\Local\Test.xlsx")
ConsoleWrite(_Excel_BackgroundColorGet($oExcel.ActiveSheet.Range("A1"), "RGB") & @CRLF) ; RGB
ConsoleWrite(_Excel_BackgroundColorGet($oExcel.ActiveSheet.Range("A1"), "Hex") & @CRLF) ; HEX
ConsoleWrite(_Excel_BackgroundColorGet($oExcel.ActiveSheet.Range("A1"), "IDX") & @CRLF) ; IDX
ConsoleWrite(_Excel_BackgroundColorGet($oExcel.ActiveSheet.Range("A1")) & @CRLF) ; Decimal color value

Func _Excel_BackgroundColorGet($oRange, $sFormat = Default)
    ; formatType: Hex for 0xRRGGBB, RGB for (R,G,B) and IDX for VBA Color Index, Default for the decimal value
    $iColorValue = $oRange.DisplayFormat.Interior.Color
    Local $vColor
    Switch $sFormat
        Case "HEX"
            $vColor = "0x" & StringLeft(Hex(Mod($iColorValue, 256)), 2) & _
                    Hex(Mod(Int($iColorValue / 256), 256), 2) & _
                    Hex(Int($iColorValue / 65536), 2)
        Case "RGB"
            $vColor = Mod($iColorValue, 256) & "," & _
                    Mod(Int($iColorValue / 256), 256) & "," & _
                    Int($iColorValue / 65536)
        Case "IDX"
            $vColor = $oRange.Interior.ColorIndex
        Case Else
            $vColor = $iColorValue
    EndSwitch
    Return $vColor
EndFunc   ;==>_Excel_BackgroundColorGet

 

I changed the path to my file. When I try the function, I get this:

 

"C:\autoit\AnotherKalenderTest.au3" (12) : ==> Variable must be of type "Object".:
ConsoleWrite(_Excel_BackgroundColorGet($oExcel.ActiveSheet.Range("D6"), "RGB") & @CRLF)
ConsoleWrite(_Excel_BackgroundColorGet($oExcel^ ERROR

 

Yours sincerely

Kenneth.

Link to comment
Share on other sites

Either you dropped the _Excel_Open statement from my example or Excel isn't installed on the machien where you run the script.
Check @error and @extended after _Excel_Open and see what's going on.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

11 hours ago, water said:

At least we come to an end ;)
If the function works I will add it as an example for others :)

I can't thank you enough.

This I couldn't figure out.

Your function works, spot on.

Yours sincerely

Kenneth.

Link to comment
Share on other sites

:)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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...