Jump to content

Recommended Posts

Posted

Did you even try my examples above?

#include <Excel.au3>
Local $oExcel = _Excel_Open()
Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Test.xlsx")

MsgBox($MB_SYSTEMMODAL, "Info", "Select cells in Excel then click OK")
Local $vRange = $oExcel.Selection.Address
;Displays message box to select range of data selected
MsgBox($MB_SYSTEMMODAL, "Title", "Range value" & $vRange & "selected")
Local $aResult = _Excel_RangeRead($oWorkbook, 1, $vRange, 2)
;Displays messagebox, instructing user to go to window to start pasting data from array
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example 2", "Error reading from workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

;~ Example 1 ~;
MsgBox(4096, "Example 1", "Example 1" & @CRLF & "Select document to send the array to.")
;~ Convert Array to String
Local $sResult = _ArrayToString($aResult, @TAB)
Send("Example 1")
Send("{ENTER}")
Send($sResult)
Send("{ENTER}")

;~ Ezample 2 ~;
MsgBox(4096, "Example 2", "Example 2" & @CRLF & "Select document to paste the string to.")
;~ Add $sResult to Clipboard
ClipPut($sResult)
;~ Paste $sResult
Send("Example 2")
Send("{ENTER}")
Send(ClipGet())
Send("{ENTER}")

;~ Example 3 ~;
MsgBox(4096, "Example 3", "Example 3" & @CRLF & "Select document to paste the string to individually.")
Send("Example 3")
Send("{ENTER}")
For $i = 0 To UBound($aResult) - 1
    For $j = 0 To UBound($aResult, 2) - 1
        Send($aResult[$i][$j])
        Sleep (150)
        Send ("{TAB}")
        Sleep(150)
    Next
    Send("{ENTER}")
Next

_ArrayDisplay($aResult)

 

Posted
  On 4/18/2019 at 4:55 PM, Subz said:

Did you even try my examples above?

#include <Excel.au3>
Local $oExcel = _Excel_Open()
Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Test.xlsx")

MsgBox($MB_SYSTEMMODAL, "Info", "Select cells in Excel then click OK")
Local $vRange = $oExcel.Selection.Address
;Displays message box to select range of data selected
MsgBox($MB_SYSTEMMODAL, "Title", "Range value" & $vRange & "selected")
Local $aResult = _Excel_RangeRead($oWorkbook, 1, $vRange, 2)
;Displays messagebox, instructing user to go to window to start pasting data from array
If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example 2", "Error reading from workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended)

;~ Example 1 ~;
MsgBox(4096, "Example 1", "Example 1" & @CRLF & "Select document to send the array to.")
;~ Convert Array to String
Local $sResult = _ArrayToString($aResult, @TAB)
Send("Example 1")
Send("{ENTER}")
Send($sResult)
Send("{ENTER}")

;~ Ezample 2 ~;
MsgBox(4096, "Example 2", "Example 2" & @CRLF & "Select document to paste the string to.")
;~ Add $sResult to Clipboard
ClipPut($sResult)
;~ Paste $sResult
Send("Example 2")
Send("{ENTER}")
Send(ClipGet())
Send("{ENTER}")

;~ Example 3 ~;
MsgBox(4096, "Example 3", "Example 3" & @CRLF & "Select document to paste the string to individually.")
Send("Example 3")
Send("{ENTER}")
For $i = 0 To UBound($aResult) - 1
    For $j = 0 To UBound($aResult, 2) - 1
        Send($aResult[$i][$j])
        Sleep (150)
        Send ("{TAB}")
        Sleep(150)
    Next
    Send("{ENTER}")
Next

_ArrayDisplay($aResult)

 

Expand  

@Subz  That's exactly what I need, it works to paste anywhere, Thanks!  I did try your suggestions  _Excel_RangeCopyPaste,  but the "if you leave $vTargetRange  as default" had me confused.  I played with it and the Ubound but no luck with both.  I've been reading up on the array's but your second variable in the Ubound is probably what I needed.  I just need to continue reading on about the Ubound, if I can find some more information on it...maybe the Wiki page.

but with some minor tweaks, this is perfect for anyone that wants to select a variable data array size and paste anywhere, in any program!

Thanks again!

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
  • Recently Browsing   0 members

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