Jump to content
Hlaurent

Excel - Filling cells from radio button groups on autoit form - help me please

Recommended Posts

Hlaurent

hi. i tried so much and at the end here i am writing this:

my problem is that i cant find a way to assign "WRITE'EM" button to send radio group values (as text or number) to a specific cell (column(x) and already selected row(selected y)) in already opened (active excel document) .

process:

WHO button :  Entries to the excel table will be one after another. So i will select the first cell manually. then i start gui and  I will press WHO. (i made it already and it works. so help that i need is not here) 

SHEET, DAYS, STARTS, WEEKEND selections will be clicked by user (me) and WRITE'EM button should send all radio-button values at once to the cells (selected row number(y) which i chose as i activate WHO button.

for example : SHEET VALUE = 43 should fill "43" cell(6,$y)
and $y is active cell row number. 

DAYS Value = 30 should fill "30" cell(7,$y)
STARTS value = "15.06.2015" cell(8,$y)
WEEKEND value ="YOK" cell(9,$y)
 

as i hit the WRITE'EM

tumblr_nop61lhUdT1rt0f83o1_500.jpg

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#Region ### START Koda GUI section ### Form=C:\Users\hloo\Documents\koda_1.7.3.0\Forms\staj_go.kxf
Global $Form1 = GUICreate("Form1", 398, 287, 445, 275)
Global $Edit1 = GUICtrlCreateEdit("", 48, 24, 329, 73)
GUICtrlSetData(-1, "Edit1")
Global $Button1 = GUICtrlCreateButton("WRITE'EM", 96, 216, 105, 33) ; sends all radio button group values to specific cells at once
Global $Button3 = GUICtrlCreateButton("WHO", 8, 24, 33, 225)
Global $Group1 = GUICtrlCreateGroup("SHEET", 48, 112, 57, 81)
Global $Radio1 = GUICtrlCreateRadio("22", 56, 136, 49, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
Global $Radio2 = GUICtrlCreateRadio("43", 56, 160, 49, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Group2 = GUICtrlCreateGroup("DAYS", 112, 112, 65, 81)
Global $Radio3 = GUICtrlCreateRadio("30", 128, 136, 33, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
Global $Radio4 = GUICtrlCreateRadio("60", 128, 160, 41, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Group3 = GUICtrlCreateGroup("STARTS", 184, 112, 105, 81)
Global $Radio5 = GUICtrlCreateRadio("15.06.2015", 200, 136, 81, 17)
Global $Radio6 = GUICtrlCreateRadio("29.06.2015", 200, 160, 81, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Group4 = GUICtrlCreateGroup("WEEKEND", 296, 112, 81, 81)
Global $Radio7 = GUICtrlCreateRadio("VAR", 312, 136, 49, 17)
Global $Radio8 = GUICtrlCreateRadio("YOK", 312, 160, 49, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

         Case $Button3
Local $i = 0
; take information from active excel, select 2 cell and send it to autoit form by simple keyboard keys - done
Do
   WinActivate("Microsoft Excel") ; go to Excel
                WinWaitActive("Microsoft Excel")
                Sleep(500)
                Send("+{RIGHT 2}")
                Sleep(500)
                Send("^c")
                Send("!{TAB}") ; back
                Sleep(500)
                Send("{TAB}")
                Send("{TAB}")
                Send("{TAB}")
                Send("{TAB}")
                Send("{TAB}")
                Send("^a")
                Send("^v")
Until GUICtrlRead($Button3) = $i
 ; copies 


;Case $Radio1 ------------------below, that i couldnt manege to make it right
;   if $Radio1 = 1 then
;     Local $belge = "22"
;   ElseIf $Radio2 = 1 then
;     Local $belge = "43"
;   Case $Radio3
;     if $Radio3 = 1 then
;     Local $gun = "30"
;   ElseIf $Radio2 = 1 then
;     Local $gun = "60"


;Case $Button1
;.cells($i, $j).value = $belge ----------------- this part that i need help most.
           EndSwitch

WEnd

i put ";" marks to my failures. if you want to help this code-poor person which is happen to be me, please don't bother to write all. just a clue would be enough.

ps: i don't need MSGBOX in any section of this. But all i find as function in examples is msgbox. 
i dont need clean excel book to open. i have students information in existed excel file and all i need to automate some specific cells again and again.

thx thx thx.

 

sry i forgot  here is the piece of excel file that i work on.

https://docs.google.com/spreadsheets/d/1Gins_bYw143qn_voZQBsCAwPMQDbwDyttg1l_qKZ5HU/edit?usp=sharing

 

Edited by Hlaurent

Share this post


Link to post
Share on other sites
MikahS

Have a look at the Excel UDF.


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites
Hlaurent

. with quote, answer is below 

Edited by Hlaurent
didn't see the quote thing at first

Share this post


Link to post
Share on other sites
Hlaurent

Have a look at the Excel UDF.

i looked there. thx for quick response btw. But that is not the answer to my deadlock.

i need an example which uses _Excel_RangeWrite whom range is consist of already selected row number and constant x for radio groups.

 

Share this post


Link to post
Share on other sites
MikahS

It looks like your trying to use dot notation on an object without a MS excel object.


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites
l3ill

Hi,

 as MikahS Mentioned you will eventually have to get cosy with the excel UDF.

But in the mean time I threw together a down and dirty example that I think might answer your question of how to get your GUI variables; radio buttons etc into an excel sheet.

This is mostly CCP' ed from the helpfile with some small changes to illustrate the point.

#include <GUIConstantsEx.au3>
#include <Excel.au3>

Example()

Func Example()
    ; Create a GUI with various controls.
    Local $hGUI = GUICreate("Example")
    Local $idOK = GUICtrlCreateButton("OK", 310, 370, 85, 25)
    Local $idSend = GUICtrlCreateButton("Send", 200, 200, 85, 25)
    Global $Radio1 = GUICtrlCreateRadio("22", 56, 136, 49, 17)
    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idOK
                ExitLoop
            Case $idSend ;---------------Send Button Calls Case $iDSend----------Case calls Function named ""SendToExcel()"" below
                SendToExcel()

        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete($hGUI)
EndFunc   ;==>Example



Func SendToExcel()

    ; Create application object and create a new workbook
    Local $oAppl = _Excel_Open()
    If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeWrite Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
    Local $oWorkbook = _Excel_BookNew($oAppl)
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeWrite Example", "Error creating the new workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
        _Excel_Close($oAppl)
        Exit
    EndIf

    ;--------------------------------------------------
    $radioVar = GUICtrlRead($Radio1)

    _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $radioVar, "A3")

    If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeWrite Example 2", "Error writing to worksheet." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

EndFunc
Edited by l3ill
effed up

Share this post


Link to post
Share on other sites
Hlaurent

Hi,

 as MikahS Mentioned you will eventually have to get cosy with the excel UDF.

But in the mean time I threw together a down and dirty example that I think might answer your question of how to get your GUI variables; radio buttons etc into an excel sheet.

This is mostly CCP' ed from the helpfile with some small changes to illustrate the point.

 what a active forum! thank you firstly. 

in your example you decided the source cell right? = A3.  

$radioVar = GUICtrlRead($Radio1)

    _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $radioVar, "A3")

but i need something like this: 

i click -for randomly example- D36 cell on already open excel doc.

can i have this :

$activeCellRow = _excelGetActiveRowValue() ; which i made up - which is my question
$constantColomn1 = 6
(then your way)

$radioVar = GUICtrlRead($Radio1)

    _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $radioVar, "$oExcel.activesheet.Cells( $constantColomn1, $activeCellRow)") <<<----instead of "A3"

ok?

i need variables comes from active-manually-clicked cell's row information instead of determinative "A3" or any thing like that. 

so i need to automate the cell ingredients. x and y from outside of user entry. 

 

Edited by Hlaurent
"column is first" fix

Share this post


Link to post
Share on other sites
MikahS

Quick example of how to get the active cell using dot notation. Don't know if it's a very elegant solution, but it gives you an idea of what to search for etc.

#include <Excel.au3>

HotKeySet("{ESC}", "Quit")

Local $oWorkbook = _Excel_Open()

_Excel_BookNew($oWorkbook)
_Excel_SheetAdd($oWorkbook)

Local $oRange = $oWorkbook.Application.Activecell.Address

Local $oAddress = StringReplace($oRange, "$", "")

MsgBox(0, "", $oAddress)

while 1

WEnd

Func Quit()
    _Excel_Close($oWorkbook)
    Exit
EndFunc

 


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites
l3ill

Sorry, I am not positive what you are going for but as mentioned before you will have to get in to the help file and play around with the examples and find the function closes to what you want to achieve and then change it accordingly.

That's how I learned :D the little bit I know...

Specifically I would start with _Excel_RangeRead

The keywords you mentioned seem to be going this direction.

BTW: There are other ways of directing data into the sheet besides A1 Range; array, 2D array, Range Object...

Edited by l3ill
msp

Share this post


Link to post
Share on other sites
l3ill

Very Cool MikahS !

So using this additional code I have updated my example.

Now you can click on your excel sheet where you want to insert and then click the send button on the GUI...

 

#include <GUIConstantsEx.au3>
#include <Excel.au3>

Example()

Func Example()
    ; Create a GUI with various controls.
    Local $hGUI = GUICreate("Example")
    Local $idOK = GUICtrlCreateButton("OK", 310, 370, 85, 25)
    Local $idSend = GUICtrlCreateButton("Send", 200, 200, 85, 25)
    Global $Radio1 = GUICtrlCreateRadio("22", 56, 136, 49, 17)
    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idOK
                ExitLoop
            Case $idSend ;---------------------------------Send Button Calls Case $iDSend----------Case calls Function named ""SendToExcel()"" below
                SendToExcel()

        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete($hGUI)
EndFunc   ;==>Example



Func SendToExcel()

    $radioVar = GUICtrlRead($Radio1)
    Local $sWorkbook = @ScriptDir & "\_Excel1.xls"
    Local $oWorkbook = _Excel_BookAttach($sWorkbook)
     Local $oRange = $oWorkbook.Application.Activecell.Address
     Local $oAddress = StringReplace($oRange, "$", "")
    _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $radioVar, $oAddress)

    If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeWrite Example 2", "Error writing to worksheet." & @CRLF & "@error = " & @error & ", @extended = " & @extended)


EndFunc   ;==>SendToExcel

 

 

 

Edited by l3ill
additional info
  • Like 1

Share this post


Link to post
Share on other sites
Hlaurent

Quick example of how to get the active cell using dot notation. Don't know if it's a very elegant solution, but it gives you an idea of what to search for etc.

Very Cool MikahS !

So using this additional code I have updated my example.

Now you can click on your excel sheet where you want to insert and then click the send button on the GUI...

 thank you both  MikahS and  I3ill very much.  i couldn't finish it today though, i feel that i m almost there with your help. 

I3ill 

your example send always "1" to the cell. but it s cool. now i know $oWorkbook.Application.Activecell.Address thing which is pretty good clue for me.  

my all au3s in my workplace. and i forgot to copy them for home. till monday,,, have a nice weekend to you.

thx again. 

Share this post


Link to post
Share on other sites
MikahS

@Hlaurent My pleasure. Let us know how it goes. 


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites
Hlaurent

done. 

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <Excel.au3>
#Region ### START Koda GUI section ### Form=C:\Users\hloo\Documents\koda_1.7.3.0\Forms\staj_go.kxf

Example()

Func Example()
Global $Form1 = GUICreate("Form1", 398, 287, 445, 275)
Global $Edit1 = GUICtrlCreateEdit("", 48, 24, 329, 73)
GUICtrlSetData(-1, "Edit1")
Global $Button1 = GUICtrlCreateButton("YAZ", 96, 216, 105, 33)
Global $Button2 = GUICtrlCreateButton("NEXT", 224, 216, 57, 33)
Global $Button3 = GUICtrlCreateButton("BILGI", 8, 24, 33, 225)
Global $Group1 = GUICtrlCreateGroup("BELGE", 48, 112, 57, 81)
Global $Radio1 = GUICtrlCreateRadio("22", 56, 136, 49, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
Global $Radio2 = GUICtrlCreateRadio("43", 56, 160, 49, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Group2 = GUICtrlCreateGroup("SÜRE", 112, 112, 65, 81)
Global $Radio3 = GUICtrlCreateRadio("30", 128, 136, 33, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
Global $Radio4 = GUICtrlCreateRadio("60", 128, 160, 41, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Group3 = GUICtrlCreateGroup("BASLAMA", 184, 112, 105, 81)
Global $Radio5 = GUICtrlCreateRadio("15.06.2015", 200, 136, 81, 17)
Global $Radio6 = GUICtrlCreateRadio("29.06.2015", 200, 160, 81, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Group4 = GUICtrlCreateGroup("CUMARTESI", 296, 112, 81, 81)
Global $Radio7 = GUICtrlCreateRadio("VAR", 312, 136, 49, 17)
Global $Radio8 = GUICtrlCreateRadio("YOK", 312, 160, 49, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
            Case $Button3
   WinActivate("Microsoft Excel") ; go to Excel
                WinWaitActive("Microsoft Excel")
                Sleep(300)
                Send("+{RIGHT 2}")
                Sleep(300)
                Send("^c")
                Send("{RIGHT}")
                Send("{RIGHT}")
                Send("{RIGHT}")
                Send("!{TAB}") ; back
                Sleep(300)
                Send("{TAB}")
                Send("{TAB}")
                Send("{TAB}")
                Send("{TAB}")
                Send("{TAB}")
                Send("^a")
                Send("^v")

          Case $Button1 ;------Send Button Calls Case $iDSend------Case calls Function named ""SendToExcel()"" below
             SendToExcel()
          Case $Button2
             WinActivate("Microsoft Excel") ; -------------------if it s wrong next
                WinWaitActive("Microsoft Excel")
                Sleep(300)
                Send("^h"); triggers excel macro to paint the cell red
                Send("{DOWN}")
                Send("{LEFT}")
                Send("{LEFT}")
                Send("{LEFT}")
                Sleep(300)
                Send("+{RIGHT 2}")
                Sleep(300)
                Send("^c")
                Send("{RIGHT}")
                Send("{RIGHT}")
                Send("{RIGHT}")
                Send("!{TAB}") ; back
                Sleep(300)
                Send("{TAB}")
                Send("{TAB}")
                Send("{TAB}")
                Send("{TAB}")
                Send("{TAB}")
                Send("{TAB}")
                Send("^a")
                Send("^v") ; back
             EndSwitch
WEnd

 EndFunc



   Func SendToExcel()
    if GUICtrlRead($Radio1) = "1" Then ; ------------------------------------------------first part
Local $setradio1 = "22"
    Local $sWorkbook = "C:\Users\hloo\Desktop\stajlar 2015 taslak\New folder\48.xlsx"
    Local $oWorkbook = _Excel_BookAttach($sWorkbook)
    Local $oRange = $oWorkbook.Application.Activecell.Address
    Local $oAddress = StringReplace($oRange, "$", "")
    _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $setradio1, $oRange)

ElseIf GUICtrlRead($Radio2) = "1" Then
    Local $setradio2 = "43"
    Local $sWorkbook = "C:\Users\hloo\Desktop\stajlar 2015 taslak\New folder\48.xlsx"
    Local $oWorkbook = _Excel_BookAttach($sWorkbook)
    Local $oRange = $oWorkbook.Application.Activecell.Address
    Local $oAddress = StringReplace($oRange, "$", "")
    _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $setradio2, $oRange)
 EndIf
 WinActivate("Microsoft Excel") ; go to Excel
                WinWaitActive("Microsoft Excel")
                Sleep(300)
                Send("{RIGHT}")
                if GUICtrlRead($Radio3) = "1" Then ;----------------------------------------second part
Local $setradio3 = "30"
    Local $sWorkbook = "C:\Users\hloo\Desktop\stajlar 2015 taslak\New folder\48.xlsx"
    Local $oWorkbook = _Excel_BookAttach($sWorkbook)
    Local $oRange = $oWorkbook.Application.Activecell.Address
    Local $oAddress = StringReplace($oRange, "$", "")
    _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $setradio3, $oRange)

ElseIf GUICtrlRead($Radio4) = "1" Then
    Local $setradio4 = "60"
    Local $sWorkbook = "C:\Users\hloo\Desktop\stajlar 2015 taslak\New folder\48.xlsx"
    Local $oWorkbook = _Excel_BookAttach($sWorkbook)
    Local $oRange = $oWorkbook.Application.Activecell.Address
    Local $oAddress = StringReplace($oRange, "$", "")
    _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $setradio4, $oRange)
 EndIf
 WinActivate("Microsoft Excel") ; go to Excel
                WinWaitActive("Microsoft Excel")
                Sleep(300)
                Send("{RIGHT}")
                Send("{RIGHT}")
                Send("{RIGHT}");-----------------------------------------------------3th part
                if GUICtrlRead($Radio5) = "1" Then
                Local $setradio5 = "15.06.2015"
    Local $sWorkbook = "C:\Users\hloo\Desktop\stajlar 2015 taslak\New folder\48.xlsx"
    Local $oWorkbook = _Excel_BookAttach($sWorkbook)
    Local $oRange = $oWorkbook.Application.Activecell.Address
    Local $oAddress = StringReplace($oRange, "$", "")
    _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $setradio5, $oRange)

ElseIf GUICtrlRead($Radio6) = "1" Then
    Local $setradio6 = "29.06.2015"
    Local $sWorkbook = "C:\Users\hloo\Desktop\stajlar 2015 taslak\New folder\48.xlsx"
    Local $oWorkbook = _Excel_BookAttach($sWorkbook)
    Local $oRange = $oWorkbook.Application.Activecell.Address
    Local $oAddress = StringReplace($oRange, "$", "")
    _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $setradio6, $oRange)
 EndIf

 WinActivate("Microsoft Excel") ; go to Excel
                WinWaitActive("Microsoft Excel")
                Sleep(300)
                Send("{LEFT}");-----------------------------------------------------4th part
                if GUICtrlRead($Radio7) = "1" Then
                Local $setradio7 = "VAR"
    Local $sWorkbook = "C:\Users\hloo\Desktop\stajlar 2015 taslak\New folder\48.xlsx"
    Local $oWorkbook = _Excel_BookAttach($sWorkbook)
    Local $oRange = $oWorkbook.Application.Activecell.Address
    Local $oAddress = StringReplace($oRange, "$", "")
    _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $setradio7, $oRange)

ElseIf GUICtrlRead($Radio8) = "1" Then
    Local $setradio8 = "YOK"
    Local $sWorkbook = "C:\Users\hloo\Desktop\stajlar 2015 taslak\New folder\48.xlsx"
    Local $oWorkbook = _Excel_BookAttach($sWorkbook)
    Local $oRange = $oWorkbook.Application.Activecell.Address
    Local $oAddress = StringReplace($oRange, "$", "")
    _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $setradio8, $oRange)
 EndIf
 WinActivate("Microsoft Excel") ;
                WinWaitActive("Microsoft Excel")
                Sleep(300)
                Send("{DOWN}")
                Send("{LEFT 6}")
                Sleep(100)
                Send("!{TAB}")
EndFunc

 

even if this s very very bad coding -i know i admit- now it's functioning very well for me. 

thx again, your contribution helped me a lot. 

Share this post


Link to post
Share on other sites
MikahS

No problem, glad you found a solution. ^_^


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
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

  • Similar Content

    • AnonymousX
      By AnonymousX
      Sorry if this is a repost, but having some trouble searching for the answer and pretty tired right now.
      I'm just wondering how to make a border around a range of cells in Excel. I want the regular lines created by selecting "All Borders" option around F2:G3
      I saw this code:
      With $oExcel.ActiveSheet.range("F2:G3") .Select .Borders($xlEdgeBottom).LineStyle = $xlContinuous .Borders($xlEdgeBottom).Weight = $xlThick .Borders($xlEdgeBottom).ColorIndex = $xlAutomatic EndWith but I get errors of these variables not existing. It seems these no longer exist in the "#include <Excel.au3>"
      Is there another include file I need?
      I got this to work for highlighting cells, wondering if there is a option similar to this for all borders?
      $oExcel.ActiveSheet.Range("F2:G3").Interior.ColorIndex = 6 Thanks
    • YouriKamperman
      By YouriKamperman
      I am working on a script that will turn all file names in a directory into an array, and then writes this Array to an Excel file.
      This in itself is working, but the RangeWrite function always puts the Array count in the first cell.
      How can i make sure this does not happen? I can of course just filter it out in Excel, but i am trying to keep all logic of filtering text in my script.
      This is what my script looks like:
      Local $Yesterday = _DateAdd('d', -1, _NowCalcDate())
      Local $cDate = StringReplace($Yesterday, "/", "-")
      Local $aFileList = _FileListToArray(@WorkingDir & "/" & $cDate, "*")
      Local $oExcel = _Excel_Open()
      Local $oWorkbook = _Excel_BookNew($oExcel)
      _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $aFileList)
    • Eminence
      By Eminence
      Hello,
      Is there a way wherein I can access the data from an array coming from an Excel file then have it assigned on to a variable?
      Below is a snippet of my current code. For now, it just reads and outputs the data from the excel file and have it displayed via an array.
      #include <Array.au3> #include <Excel.au3> #include <MsgBoxConstants.au3> Local $oExcel = _Excel_Open(False) If @error Then Exit MsgBox(0, "Error", "Error creating application object." & @CRLF & "Error: " & @error & " Extends: " & @extended) ; Open Excel Woorkbook and return object Local $sWorkbook = @ScriptDir & "\Excel Files\Test Data.xlsx" Local $oWorkbook = _Excel_BookOpen($oExcel, $sWorkbook, False, True) If @error Then MsgBox(0, "Error", "Error opening workbook'" & $sWorkbook & ".'" & @CRLF & "Error: " & @error & "Extends: " & @extended) _Excel_Close($oExcel) Exit EndIf Local $aResult = _Excel_RangeRead($oWorkbook) ; Error Trapping If @error Then MsgBox(0, "Error", "Error reading data from '" & $sWorkbook & ".'" & @CRLF & "Error: " & @error & " Extends: " & @extended) _Excel_Close($oExcel) Exit EndIf _ArrayDisplay($aResult) My Excel file has values from Column A to H with values from 1 to 30, what I desired to do is have the value in "A7" assigned on to a variable. 
       
      Any help is appreciated. Thanks in advance.
    • JNutt
      By JNutt
      I am trying to close an excel file that was not opened with _Excel_Open.  How do I found the excel application object?  I'm new and I am used to files and folders names, so an 'object' is new to me.  I have the info too and simply spy, but I don't know which info is the object name/string.  In the example from help doc's I see the code below and I tried justin pasting it into Scite.
      <
      Local $oExcel1 = ObjCreate("Excel.Application")
      ; Close the Excel instance which was not opened by _Excel_Open
      ; (will still be running because it was not opened by _Excel_Open)
      _Excel_Close($oExcel1)
      If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Close Example 1", "Error closing the Excel application." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
      Sleep(2000)
      Local $aProcesses = ProcessList("Excel.exe")
      MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_Close Example 1", "Function ended successfully." & @CRLF & @CRLF & $aProcesses[0][0] & " Excel instance(s) still running.")
      >
    • rudi
      By rudi
      Hello,
      I used the various "_Excel_*()" funktions to open workbooks, read and write cells.
       
      I was looking through the helpfile for the _EXCEL_* funktions, if there is a direkt way to set background color or text color -- if there is one, then I missed it?
       
      Searching the forum I found this posting demonstrating how to do this task using ...
      ObjCreate("Excel.Application")  
      Is there a way to set the background color etc. with the native "_EXCEL_*" as well?
       
      Regards, Rudi.
       
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.