Jump to content

Copy Excel cell value from book already open


Recommended Posts

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

Link to comment
Share on other sites

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!
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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..

Link to comment
Share on other sites

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)
Link to comment
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
 Share

  • Recently Browsing   0 members

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