Sign in to follow this  
Followers 0
232showtime

_Excel_RangeRead help

2 posts in this topic

#1 ·  Posted (edited)


I want to rangeread B14 to B26, by pressing F9.. like if i press F9 will read B14 and by pressing F9 again will read next cell B15, but i dont have any idea to rangeread the next cell using F9 again. is it possible?

HotKeySet("{F9}", "Copy")
Func Copy()
If WinActivate("[CLASS:XLMAIN]") Then
Local $sText = WinGetTitle("[ACTIVE]")
$iText = StringLeft($sText, 16)
Local $sWorkbook = $iText & ".xlsx"
$oWorkbook = _Excel_BookAttach($sWorkbook, "filename")
Local $sResult = _Excel_RangeRead($oWorkbook, Default, "B14")
ControlSetText("Untitled - Notepad", "", "[CLASS:Edit; INSTANCE:1]", $sResult)
EndIf
Endfunc
Edited by 232showtime

ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

Share this post


Link to post
Share on other sites



A simple exampleto get you started F9 starts the script, F10 ends the script. The cell is being written to the Console. It starts with B14 but does not stop reading when B26 is being reached.

#include <Excel.au3>
#include <StringConstants.au3>
HotKeySet("{F9}", "_Copy")
HotKeySet("{F10}", "_Exit")
Global $iStart = 13, $iEnd = 26, $iIndex = $iStart
While 1
    Sleep(10)
WEnd
Func _Copy()
    If WinActivate("[CLASS:XLMAIN]") Then
        Local $sTitle = WinGetTitle("[ACTIVE]")
        Local $aTitle = StringSplit($sTitle, " - ", $STR_ENTIRESPLIT)
        $oWorkbook = _Excel_BookAttach($aTitle[2], "filename")
        Local $sResult = _Excel_RangeRead($oWorkbook, Default, "F" & $iIndex)
        $iIndex = $iIndex + 1
        ConsoleWrite($sResult & @CRLF)
;       ControlSetText("Untitled - Notepad", "", "[CLASS:Edit; INSTANCE:1]", $sResult)
    EndIf
EndFunc   ;==>_Copy
Func _Exit()
    Exit
EndFunc   ;==>_Exit
1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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
Sign in to follow this  
Followers 0