Jump to content

Use _ExcelWriteCell with Active Workbook


Recommended Posts

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

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

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.

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