Results 1 to 8 of 8

Thread: Hooking the VTABLE of an Event Interface ?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2009
    Posts
    64

    Hooking the VTABLE of an Event Interface ?

    Hi all,

    Is it possible to hook the VTable of an Event Interface such as the ICommandBarButtonEvents of the Microsoft Office Object Library ? ICommandBarButtonEvents Interface GUID ="{55F88890-7708-ACEB-C000-006008961DA5}"

    I can successfully hook the Properties and Methods but not the Click event

    Thank you
    Last edited by RAFAAJ2000; Aug 7th, 2016 at 02:32 AM.

  2. #2
    Fanatic Member
    Join Date
    Nov 2013
    Posts
    658

    Re: Hooking the VTABLE of an Event Interface ?

    Bump

    Any thoughts anyone ?

  3. #3
    Fanatic Member
    Join Date
    Nov 2013
    Posts
    658

    Re: Hooking the VTABLE of an Event Interface ?

    Nobody ?

  4. #4
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,910

    Re: Hooking the VTABLE of an Event Interface ?

    I've never done it from VB6, but it's possible, at least in some form.

    My wife is a professor, and she uses this little program called PhraseExpress that somehow latches itself onto Word. When she's reviewing student papers, she has "codes" that she can type in, like "arpq". When she types in these codes, Word (via PhraseExpress) will automatically do various tasks, like possibly make a side-bar comment that's an entire paragraph. I've never used it, but apparently it can do many things from just typing in these codes that you create.

    However, the more I think about it, it's probably an add-in into Word, which probably does give you some access to events within Word (such as document_changed). I try to stay away from the VBA and various add-ins as much as I can, but I'm sure there are ways to do it.

    To actually contemplate doing it from VB6 though would be a bit strange. This would be a bit like a keyboard sniffer, which is rather discouraged.

    Elroy
    Regards,
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  5. #5

  6. #6
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    10,910

    Re: Hooking the VTABLE of an Event Interface ?

    @Trick, I think he's wanting to hook events in MS-Word and see them in VB6, sort of like "WithEvents" for a word document. The methods are trivially "hooked" by just using automation.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  7. #7
    Member Dragokas's Avatar
    Join Date
    Aug 2015
    Location
    Ukraine on fire (country of slaves)
    Posts
    750

    Re: Hooking the VTABLE of an Event Interface ?

    Quote Originally Posted by Elroy
    I think he's wanting to hook events in MS-Word and see them in VB6, sort of like "WithEvents" for a word document. The methods are trivially "hooked" by just using automation.
    Hmm, if so, RAFAAJ2000, no need to hook. Just use standard strategy.
    Here is an example:

    Code:
    Option Explicit
    
    Private WithEvents oButton  As CommandBarButton
    
    Private oWord As Word.Application
    
    Private Sub cmdCreate_Click()
        
        Dim PanelName   As String
        Dim oDoc        As Word.Document
        Dim oBars       As CommandBars
        Dim oBar        As CommandBar
        
        Set oWord = New Word.Application
        
        With oWord
            .Visible = True
            .Activate
            .WindowState = wdWindowStateMaximize
            
            Set oDoc = .Documents.Add(, , , True)
        End With
        
        Set oDoc = oWord.Documents(1)
        Set oBars = oDoc.CommandBars
        
        PanelName = "My Bar"
        
        Set oBar = oBars.Add(Name:=PanelName, Position:=msoBarTop, _
                MenuBar:=False, Temporary:=True)
        
        oBar.Enabled = True
        oBar.Visible = True
        
        Set oButton = oBar.Controls.Add(Type:=msoControlButton)
        
    End Sub
    
    Private Sub cmdClose_Click()
        oWord.Documents.Close False
        oWord.Quit
        Set oWord = Nothing
    End Sub
    
    Private Sub oButton_Click(ByVal Ctrl As CommandBarButton, CancelDefault As Boolean)
        MsgBox "Event: CommandBar Button Clicked."
    End Sub
    Add references to:
    1. Microsoft Office xx Object Library
    2. Microsoft Word xx Object Library

    and 2 buttons on VB Form cmdCreate and cmdClose. Run, press cmdCreate, switch to Word, press button on new bar, so, you'll get event in your app.

    Best regards,
    Alex.
    Malware analyst, VirusNet developer, HiJackThis+ author || my CodeBank works

  8. #8
    Fanatic Member
    Join Date
    Nov 2013
    Posts
    658

    Re: Hooking the VTABLE of an Event Interface ?

    Thanks for answering but hooking the CommandBarButton Click event in the way that Elroy and Dragokas kindly suggested only works with versions of Office prior to Office 2007 .. With the advent of the Ribbon in Office 2007 and later, that approach does'nt work anymore

    Still hoping to find an API based (low level) solution.

    Regards

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width