Jump to content

Using COM


Recommended Posts

Interesting trick. Is it just a graphic element in IE, or is there an instance of Excel running on the client, or are you viewing a remote Citrix desktop, or... what?

:)

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

not sure but check the attachment

the menu is excel style not IE...

If it's a local instance of Excel running as an ActiveX object in IE, then _ExcelBookAttach() should work. Did you try it?

:)

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

It is an activeX control hosted in the browser.

See if you can get attached to it with _ExcelBookAttach (may not be exact function name).

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

It is an activeX control hosted in the browser.

See if you can get attached to it with _ExcelBookAttach (may not be exact function name).

Dale

I had suggested that, but there may be an issue. The only matching modes available are:

FileName - Name of the open workbook

FilePath - (Default) Full path to the open workbook

Title - Title of the Excel window

I don't know where you get the matching string for any of those in this case, and it doesn't accept "".

Adding the default return of the first workbook if $s_string = "" has already been suggested. This might be a good time to try it:

; #FUNCTION# ====================================================================================================================
; Name...........: _ExcelBookAttach
; Description ...: Attach to the first existing instance of Microsoft Excel where the search string matches based on the selected mode.
; Syntax.........: _ExcelBookAttach($s_string[, $s_mode = "FilePath"])
; Parameters ....: $s_string - String to search for, "" returns first workbook in collection
;                  $s_mode   - Optional: specifies search mode:
;                  |FileName - Name of the open workbook
;                  |FilePath - (Default) Full path to the open workbook
;                  |Title    - Title of the Excel window
; Return values .: Success   - Returns an object variable pointing to the Excel.Application, workbook object
;                  Failure   - Returns 0 and sets @ERROR = 1
; Author ........: Bob Anthony (big_daddy)
; Modified.......: PsaltyDS 11/05/09 - add default to return first workbook if $s_string = ""
; Remarks .......:
; Related .......: _ExcelBookNew, _ExcelBookOpen
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _ExcelBookAttach($s_string, $s_mode = "FilePath")

    Local $o_Result

    If $s_mode = "filepath" Then
        $o_Result = ObjGet($s_string)
        If Not @error And IsObj($o_Result) Then
            Return $o_Result
        EndIf
    EndIf

    $o_Result = ObjGet("", "Excel.Application")
    If @error Or Not IsObj($o_Result) Then
        Return SetError(1, 1, 0)
    EndIf

    Local $o_workbooks = $o_Result.Application.Workbooks
    If Not IsObj($o_workbooks) Or $o_workbooks.Count = 0 Then
        Return SetError(1, 2, 0)
    EndIf

    For $o_workbook In $o_workbooks
        ; Return first available if $s_string = ""
        If $s_string = "" Then Return $o_workbook

        Switch $s_mode
            Case "filename"
                If $o_workbook.Name = $s_string Then
                    Return $o_workbook
                EndIf
            Case "filepath"
                If $o_workbook.FullName = $s_string Then
                    Return $o_workbook
                EndIf
            Case "title"
                If ($o_workbook.Application.Caption) = $s_string Then
                    Return $o_workbook
                EndIf
            Case Else
                Return SetError(1, 3, 0)
        EndSwitch
    Next

    Return SetError(1, 5, 0)
EndFunc   ;==>_ExcelBookAttach

:)

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

I couldn't get _ExcelBookAttach to work, I ended up using controlClick, and several other lines to get what i needed.

The change in ExcelBookAttach would add much more functionality to the function!

Not if it doesn't work... did you try the modified version I posted? I was hoping for a cheap test there...

:)

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

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