Sign in to follow this  
Followers 0
ezzetabi

Taking Excel Content...

6 posts in this topic

...I know that Microsoft app do not use Microsoft controls, but I'd like to know if exist a way to go in a cell and take its content using the controls and not just {F5} -> cell number -> {enter} -> {F2} -> {end}+{home}^c -> {esc}

I aim making a script that take some cells and copy them in a cvs file, so it will be a combination of cell taking and filewrite.

Thanks for support.

Share this post


Link to post
Share on other sites



bump... Please :whistle:

Share this post


Link to post
Share on other sites

Sorry, you can do a few things, but Microsoft doesn't always obey thier same rules, and I can't remember how exactly to do any more shortcuts, but you can use these controls to keep it a bit more reliable perhapse.

$x=getcell("b6")
MsgBox(1, "Cell contents",$x)

Func getcell($_cell)
winactivate("Microsoft Excel")
ControlSend("Microsoft Excel","","XLDESK1","{f5}")
While NOT ControlCommand ("Go To","","EDTBX1","IsVisible", "") ; wait for window
sleep(100)
Wend
ControlSend("Go To","","EDTBX1",$_cell&"{enter}")
ControlSend("Microsoft Excel","","XLDESK1","^c"); copies contents
$x=clipget(); move clipboard to $x
ControlSend("Microsoft Excel","","XLDESK1","{esc}"); return excel to normal state
Return $x
EndFunc

AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

I first came across AutoIt when I was looking for a solution involving scripting some programs and placing the extracted data into Excel (kinda opposite to what you are doing, if I read you correctly).

After much trial and error I found it was easier to just do everything in VBA, since as it was said, it isn't easy to get at MS products from the outside. So I worked from the inside out. It supports all the file i/o, sending keystrokes to other programs, etc. you could probably want, with the bonus of being able to access worksheet elements natively. The syntax is similar, and the help file is adequate. Lots of help by recording your own macros and looking at them.

I feel like I should apologize for not having an AutoIt solution, maybe a hybrid solution? I guess it depends if the bulk of your work needs to be done in Excel or not.

Share this post


Link to post
Share on other sites

Thanks etn.

Share this post


Link to post
Share on other sites

One thing I do is program all the excel stuff I want in vba in excel, then tie it to a macro command key. then, just get autoit to send the command. Ie: sort a list is invoked by ^l,


If I had a really good sig file, this is where it would go.

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