Jump to content
Sign in to follow this  

Question: COM object on a Tab

Recommended Posts



Is it possible to embed a COM object on a tab sheet with GuiCtrlCreateObject()?

The Excel object that I am trying to embed is misbehaving, but before I post any code, I wanted to make sure that Autoit3 beta 126 supports this functionality. I cannot find any reference in the helpfile.

EDIT: No replies... guess I'll post some code!

The COM object is created, but it appears on the first tab instead of the second tab when the GUI is first loaded. Also, there are a lot of problems sending input to the sheet. Pressing enter after entering data makes the sheet (but not the toolbar) flicker and disappear.

Here's the code.

#include <GUIConstants.au3>
#Include <GuiTab.au3>

$window_title = "Tools"
$frm_main = GUICreate($window_title, 627, 317, -1, -1, BitOr($GUI_SS_DEFAULT_GUI, $WS_SYSMENU, $WS_VISIBLE, $WS_CLIPSIBLINGS, $WS_OVERLAPPEDWINDOW))

$Tab1 = GUICtrlCreateTab(0, 4, 625, 273)
    $TabSheet1 = GUICtrlCreateTabItem("First")
        $ednums = GUICtrlCreateEdit("", 8, 33, 121, 240, BitOr($ES_WANTRETURN, $WS_VSCROLL, $ES_AUTOVSCROLL, $ES_MULTILINE, $WS_TABSTOP, $ES_NUMBER), $WS_EX_CLIENTEDGE)
    $TabSheet2 = GUICtrlCreateTabItem("Second")
        _GUICtrlCreateListViewEnhanced("Col1|Col2|Col3", 3, 33, 250, 235)
    $TabSheet3 = GUICtrlCreateTabItem("Third")
    ;another excel com object?
_GUICtrlTabSetMinTabWidth($Tab1, 100)
While 1
    $msg = GuiGetMsg()
    Case $msg = $GUI_EVENT_CLOSE
    Case $msg = $Tab1

        If GuiCtrlRead($Tab1) = 0 Then      ;TAB1 DYNAMIC FUNCTIONS

        Elseif GuiCtrlRead($Tab1) = 1 Then  ;TAB2 DYNAMIC FUNCTIONS

        Elseif GuiCtrlRead($Tab1) = 2 Then  ;TAB3 DYNAMIC FUNCTIONS


;GuiCtrlCreateListViewEnhanced (Taken from Ptrex's SQLite3 GUI)

Func _GUICtrlCreateListViewEnhanced($col_names,$left,$top,$width,$height)   
;Create Spreadsheet object.
    if RegRead("HKCR\OWC9.spreadsheet","") then $ExcelLV = ObjCreate("OWC9.spreadsheet")
    if RegRead("HKCR\OWC10.spreadsheet","") then $ExcelLV = ObjCreate("OWC10.spreadsheet")
    if RegRead("HKCR\OWC11.spreadsheet","") then $ExcelLV = ObjCreate("OWC11.spreadsheet")
    If IsObj($ExcelLV) Then
        with $ExcelLV
            .AllowPropertyToolbox = True
            .DisplayOfficeLogo = false
            .DisplayPropertyToolbox = False 
            .DisplayTitleBar = False 
            .DisplayToolbar = False
        ;.ViewOnlyMode = True
        ;.autofit = True
        ;.Maxwidth = 1000
        ;.Maxheight = 1000

        With $ExcelLV.ActiveWindow
            .DisplayGridlines = True
            .DisplayHorizontalScrollBar = True
            .DisplayVerticalScrollBar = True
            .DisplayColumnHeadings = True
            .DisplayRowHeadings = True   
            .DisplayWorkbookTabs = False        
            .EnableResize = false
        $owcWbook = $ExcelLV.ActiveWorkbook
        $GUI_ActiveX = GUICtrlCreateObj($ExcelLV,$left,$top,$width,$height)     
    ;$ExcelLV.Activewindow.FreezePanes = True   
        $TempHeadingArray = stringsplit($col_names,"|")

    with $ExcelLV
        for $i = 1 to $tempheadingarray[0]
        ;.cells(1,$i).value = $tempheadingarray[1]
            .activewindow.columnheadings($i).caption = $Tempheadingarray[$i]
       MsgBox(0,"Reply","You don't appear to have the office web components installed. If you are using Office 2000, the components do not support spreadsheets. Sorry.",4)

Thanks in advance for looking.

Edited by syberschmo

Share this post

Link to post
Share on other sites

Bump. I posted some code.

The main alternative (Editable listview) is undergoing some revision at the moment.

Is an Excel com object possible?

By the way, I have office 10.

Share this post

Link to post
Share on other sites


Have subsequently confirmed the error with both Office 10 and 11 Excel objects. I'm guessing COM-object tab functionality is not possible??

Please, someone knowledgeable post a boolean response to verify my assumption. :D

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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.