Opened 11 years ago

Last modified 11 years ago

#2295 closed Feature Request

Help on ObjGet — at Version 2

Reported by: MvL Owned by:
Milestone: 3.3.9.5 Component: Documentation
Version: Severity: None
Keywords: ObjGet Cc:

Description (last modified by trancexx)

I had to add an empty function, to make example two work,
in the help on ObjGet.

   Func nothing()
   EndFunc

Also,
in order to activate the worksheet, I added

$oExcelDoc.Application.Windows($Worksheet).Activate

in the code below,
See also my Example script:

Getting the right Excel window, using ObjGet

Local $Worksheet = "Worksheet.xls"
Local $Filename = "C:\" & $Worksheet

If Not FileExists($FileName) Then
    MsgBox(0, "Excel File Test", "Can't run this test, because you didn't create the Excel file " & $FileName)
    Exit
EndIf

Local $oExcelDoc = ObjGet($FileName) ; Get an Excel Object from an existing filename


If IsObj($oExcelDoc) Then

    ; Tip: Uncomment these lines to make Excel visible (credit: DaleHohm)
    $oExcelDoc.Windows(1).Visible = 1; Set the first worksheet in the workbook visible
    $oExcelDoc.Application.Visible = 1; Set the application visible (without this Excel will exit)

; and:
    $oExcelDoc.Application.Windows($Worksheet).Activate

    Local $String = "" ; String for displaying purposes

    ; Some document properties do not return a value, we will ignore those.
    Local $OEvent = ObjEvent("AutoIt.Error", "nothing"); Equal to VBscript's On Error Resume Next

    For $Property In $oExcelDoc.BuiltinDocumentProperties
        $String = $String & $Property.Name & ":" & $Property.Value & @CRLF
    Next

    MsgBox(0, "Excel File Test", "The document properties of " & $FileName & " are:" & @CRLF & @CRLF & $String)

    ; $oExcelDoc.Close ; Close the Excel document

Else
    MsgBox(0, "Excel File Test", "Error: Could not open " & $FileName & " as an Excel Object.")
EndIf

Change History (2)

comment:1 Changed 11 years ago by TicketCleanup

  • Version 3.3.8.1 deleted

Automatic ticket cleanup.

comment:2 Changed 11 years ago by trancexx

  • Description modified (diff)

The line with ObjEvent needs to go away from current example.

Note: See TracTickets for help on using tickets.