Jump to content
Sign in to follow this  
Snow1

Copy Excel cell value from book already open

Recommended Posts

Snow1

From a real newbe.

I can't find any information on how to read/copy an excel cell value from an already opened workbook sheet.I can't use a read only.

All I want to do is copy a cell value to paste into another windows application. Nothing I can find works, except Read Only!

Thanks

Share this post


Link to post
Share on other sites
MrMitchell

Help File --> Excel Management

Share this post


Link to post
Share on other sites
Snow1

Help File --> Excel Management

Thanks for quick reply

I looked there...it has OpenBookNew but that has blank cells. I just want to read/copy from the workbook already open.

Share this post


Link to post
Share on other sites
MrMitchell

Try _ExcelBookAttach() :huh2:

Then _ExcelReadCell()

Edited by MrMitchell

Share this post


Link to post
Share on other sites
Snow1

Try _ExcelBookAttach() :huh2:

Then _ExcelReadCell()

Thank you but that won't work either. I guess Autoit doesn't work with an already opened workbook. I was trying to get away from SendKeys which does work but very unreliable!

Share this post


Link to post
Share on other sites
MrMitchell

Thank you but that won't work either. I guess Autoit doesn't work with an already opened workbook. I was trying to get away from SendKeys which does work but very unreliable!

It does too work with a Workbook that's already open, that's what _ExcelBookAttach() does. How are you using the command?

Edit1: You can make reference to your open workbook using 3 different strings: file name, full path and filename, or title of the Excel window.

Edit2: Check out the 3 examples in the Help File, you'll get a good idea on how it works.

Edited by MrMitchell

Share this post


Link to post
Share on other sites
Snow1

It does too work with a Workbook that's already open, that's what _ExcelBookAttach() does. How are you using the command?

Edit1: You can make reference to your open workbook using 3 different strings: file name, full path and filename, or title of the Excel window.

Edit2: Check out the 3 examples in the Help File, you'll get a good idea on how it works.

Well,I'm getting closer, thanks for your help. Now my problem is that it won't read a cell. I even use write to cell but it won't read it: This is what I have:

$oExcel = _ExcelBookAttach("c:\Documents and Settings\dick\My Documents\Book1.xls")

_ExcelWriteCell($oExcel, "Uploading", 1, 1)

$sCellValue = _ExcelReadCell($oExcel, 1, 1)

It writes "Uploading" to cell A1 but always reads "_ExcelWriteCell($oExcel, "Uploading", 1, 1)".

No matter what it writes, the results are always the same.

What am I doing wrong???

Thanks again..

Share this post


Link to post
Share on other sites
JoHanatCent

What am I doing wrong???

Thanks again..

Maybe time to check if indeed you had a successful attachment?

#Include <Excel.au3>
$oExcel = _ExcelBookAttach("c:\Documents and Settings\dick\My Documents\Book1.xls")
If @error = 1 Then MsgBox(0, "Error code is: "&@error, "Could not Attach Excel Book returning: " &$oExcel)
 _ExcelWriteCell($oExcel, "Uploading", 1, 1)
 $sCellValue = _ExcelReadCell($oExcel, 1, 1)

Share this post


Link to post
Share on other sites
Snow1

Thanks to all your help I got the right script.

have a great day..

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  

×