Subz Posted April 18, 2019 Posted April 18, 2019 Did you even try my examples above? expandcollapse popup#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)
msmith83100 Posted April 18, 2019 Author Posted April 18, 2019 On 4/18/2019 at 4:55 PM, Subz said: Did you even try my examples above? expandcollapse popup#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!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now