Jump to content

Excel ActiveCell Not working


Recommended Posts

OK, I think I found the problem and modified your original script:

#include <IE.au3>
#include <Array.au3>
#include <Excel.au3>
#include <GUIConstantsEx.au3>
Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc"); User's COM error function. Will be called if COM error occurs
Func _ErrFunc($oError)  
    ; Do anything here.
    ConsoleWrite("err.number is: " & @TAB & $oError.number & @CRLF & _        
        "err.windescription:" & @TAB & $oError.windescription & @CRLF & _         
        "err.description is: " & @TAB & $oError.description & @CRLF & _     
        "err.source is: " & @TAB & $oError.source & @CRLF & _         
        "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _         
        "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _     
        "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _         
        "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _         
        "err.retcode is: " & @TAB & $oError.retcode & @CRLF & @CRLF)
    EndFunc   ;==>_ErrFunc

$oExcel = _ExcelBookAttach("C:\Golden Medical Billing\Clients\Dr. Meglio\Aging Reports\2012\Meglio Aging 03-08-12.xlsx") ; Returns the Workbook object, not the application object
If @error = 1 Then MsgBox(0, "Error code is: "& @error, "Could not Attach Excel Book returning: " & $oExcel)
  
$oActiveCell = $oExcel.Application.ActiveCell.Value
Link to comment
Share on other sites

Nice. Completely overlooked the Application object.

Still don't get why _ExcelBookAttach function is being used though. (edit: Must have the Excel file open already and "attaching" $oExcel to the workbook.)

Edited by Reg2Post
Link to comment
Share on other sites

You're welcome. Of course, if you continue to use the $oExcel object for other properties and methods, it may be easier to do something like this:

$oExcel = _ExcelBookAttach("C:Golden Medical BillingClientsDr. MeglioAging Reports2012Meglio Aging 03-08-12.xlsx")
$oExcel = $oExcel.Application
$oActiveCell = $oExcel.ActiveCell.Value

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