Jump to content
Sign in to follow this  
newbie28

Use _ExcelWriteCell with Active Workbook

Recommended Posts

newbie28

Hello,

I want to use _ExcelWriteCell with whatever excel workbook is currently active, but I'm not sure how to set $oExcel in order to do this. Any suggestions? Thank you!!

Share this post


Link to post
Share on other sites
PsaltyDS

I want to use _ExcelWriteCell with whatever excel workbook is currently active, but I'm not sure how to set $oExcel in order to do this. Any suggestions? Thank you!!

_ExcelAttach()

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
newbie28

Is there a way to set any open workbook as the object, whatever file name it might have? Right now, I can only get it to work if I know the exact title/filename of the workbook. Thank you! :)

Share this post


Link to post
Share on other sites
PsaltyDS

Is there a way to set any open workbook as the object, whatever file name it might have? Right now, I can only get it to work if I know the exact title/filename of the workbook. Thank you! :)

Get the window title using the class (i.e. WinGetTitle("[CLASS:XLMAIN]", "")). Then use that in _ExcelBookAttach() with the "Title" parameter.

:)

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
newbie28

Awesome, thank you!!

Share this post


Link to post
Share on other sites
Malkey

To help others who search these forums for assistance, here is an example of using _ExcelBookAttach () to write to the cell of an open Excel worksheet / workbook.

;
; http://www.autoitscript.com/forum/index.php?s=&showtopic=97570&view=findpost&p=701571
 #include <Excel.au3>
 
 Local $sExcelWinTitle, $oExcel
 
 $sExcelWinTitle = WinGetTitle("[CLASS:XLMAIN]", "")
 
 If $sExcelWinTitle <> "" Then
     $oExcel = _ExcelBookAttach($sExcelWinTitle, "Title")
     WinActivate("[CLASS:XLMAIN]", "")
 
     For $i = 1 To 20;Loop
         _ExcelWriteCell($oExcel, " I Wrote to This Cell", $i, 1);Write to the Cell
     Next
 EndIf
;

newbie28 should have posted a solution for those who follow in his footsteps - like me.

Thanks PsaltyDS.

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  

×