Sign in to follow this  
Followers 0
elmer92413

Pasting Arrays into Excel

6 posts in this topic

WinWaitActive("Microsoft Excel - Voice Mailboxes.xls")
Sleep(5000)
Global $array
Do
    Send("^c")
    $clipboard = ClipGet()
    $array = StringSplit($clipboard, ",")
    $firstName = $array[2]
    $lastName = $array[1]
    ClipPut($firstName & " " & $lastName)
    Send("^v")
    Send("{DOWN}")
Until $clipboard = ""

When it copies into Excel it uses two cells... :lmao:

The original cell, where I want it to go...

And the cell below it, where the next name is...

It then moves "Down"

Tries to loops but when it copies just one name $array[2] returns an error...!!!

It doesn't exist the second time...

Does anybody know what I am doing wrong or how to correct this...???

Is this code just not possible or what...??? o:)

Share this post


Link to post
Share on other sites



WinWaitActive("Microsoft Excel - Voice Mailboxes.xls")
Sleep(5000)
Global $array
Do
    Send("^c")
    $clipboard = ClipGet()
    $array = StringSplit($clipboard, ",")
    $firstName = $array[2]
    $lastName = $array[1]
    ClipPut($firstName & " " & $lastName)
    Send("^v")
    Send("{DOWN}")
Until $clipboard = ""

When it copies into Excel it uses two cells... :huh:

The original cell, where I want it to go...

And the cell below it, where the next name is...

It then moves "Down"

Tries to loops but when it copies just one name $array[2] returns an error...!!!

It doesn't exist the second time...

Does anybody know what I am doing wrong or how to correct this...???

Is this code just not possible or what...??? :(

<{POST_SNAPBACK}>

Try StringStripWS($clipboard, 8) before your stringsplit

I do not think that you will ever get

$clipboard = "" since you are assiging " " within the loop

That is all that I can suggest at the moment - got to run...


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

After looking futher into this...

I have come to the conclusion that for some reason when you copy a cell you get a carriage return at the end...

I have tried stripping the carriage return but to no avail...

I am going to try to replace it with white space... :lmao:

...

..

.

Share this post


Link to post
Share on other sites

After looking futher into this...

I have come to the conclusion that for some reason when you copy a cell you get a carriage return at the end...

I have tried stripping the carriage return but to no avail...

I am going to try to replace it with white space... :lmao:

...

..

.

<{POST_SNAPBACK}>

Per the docs, StringStripWS($string,8) should give you the value with no whitespace and no @cr/@lf/@crlf.

Whitespace includes Chr(9) thru Chr(13) which are HorizontalTab, LineFeed, VerticalTab, FormFeed, and CarriageReturn. Whitespace also includes the null string ( Chr(0) ) and the standard space ( Chr(32) ).


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

Per the docs, StringStripWS($string,8) should give you the value with no whitespace and no @cr/@lf/@crlf.

<{POST_SNAPBACK}>

Nope doesn't work...

I even stopped my script before it pasted back into Excel and manually pasted it into NotePad and still got it on two lines...!!!

I am going to try a new approach :lmao: and have it pasted into NotePad and backspace to get ride of the carriage return...

Hopefully it works... o:)

Share this post


Link to post
Share on other sites

I got it to work...!!! o:)

I made it paste into NotePad and then Backspace to manually ge rid of the carriage return...

WinWaitActive("Microsoft Excel - Voice Mailboxes.xls")
Run("notepad.exe", "", @SW_MINIMIZE)
Sleep(1000)
Global $array
Global $arranged
Send("^c")
Do
    WinActivate("Untitled - Notepad")
    Send("^v{BS}{SHIFTDOWN}{CTRLDOWN}{HOME}{SHIFTUP}{CTRLUP}^x")
    WinActivate("Microsoft Excel - Voice Mailboxes.xls")
    $clipboard = ClipGet()
    $array = StringSplit($clipboard, ",")
    $firstName = $array[2]
    $lastName = $array[1]
    $arranged = String($firstName & " " & $lastName)
    ClipPut($arranged)
    Send("^v")
    Send("{DOWN}")
    Send("^c")
Until $clipboard = ""

The only problem now was that it won't scroll past the bottom of the screen...

But it's not that big of a deal if you scroll out far enough... :lmao:

Thanks for all the input...!!!

...

..

.

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