Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Events from document opened with Shell.Explorer

Subject: Events from document opened with Shell.Explorer

From: Zach

Date: 24 Feb, 2011 20:51:05

Message: 1 of 3

I'm looking to embed an excel document into a figure. My options are either using OWC.11 or using Shell.Explorer to open the file and display it. I prefer the latter, because the file is opened with the full excel application, while OWC.11 is paired down and doesn't contain a lot of features that excel has available.

My example code is:
figure ('pos', [100 100 780 420])
hBrowser = actxcontrol ('Shell.Explorer.2', [0 0 780 420]); %Also tried 'Shell.Explorer'
assignin('base','hBrowser',hBrowser)
invoke (hBrowser, 'Navigate', 'file://C:\test.xls');

hBrowser.registerevent(@testing) %I see these events
hBrowser.eventlisteners %Lists all of the events that were registered
hBrowser.Document.registerevent(@testing) %I dont see these events
hBrowser.Document.eventlisteners %Is empty?
hBrowser.Document.Application.registerevent(@testing) %I dont see these events
hBrowser.Document.Application.ActiveSheet.registerevent(@testing) %I dont see these events
hBrowser.Document.Application.ActiveWindow.registerevent(@testing) %I dont see these events
hBrowser.Document.Application.ActiveWorkbook.registerevent(@testing) %I dont see these events

I would like to be able to view events on the excel document that is opened, but for some reason it doesn't look like they're properly registered. Anyone have any ideas?

Subject: Events from document opened with Shell.Explorer

From: Donn Shull

Date: 10 Mar, 2011 17:43:05

Message: 2 of 3

"Zach" wrote in message <ik6gbp$1gs$1@fred.mathworks.com>...
> I'm looking to embed an excel document into a figure. My options are either using OWC.11 or using Shell.Explorer to open the file and display it. I prefer the latter, because the file is opened with the full excel application, while OWC.11 is paired down and doesn't contain a lot of features that excel has available.
>
> My example code is:
> figure ('pos', [100 100 780 420])
> hBrowser = actxcontrol ('Shell.Explorer.2', [0 0 780 420]); %Also tried 'Shell.Explorer'
> assignin('base','hBrowser',hBrowser)
> invoke (hBrowser, 'Navigate', 'file://C:\test.xls');
>
> hBrowser.registerevent(@testing) %I see these events
> hBrowser.eventlisteners %Lists all of the events that were registered
> hBrowser.Document.registerevent(@testing) %I dont see these events
> hBrowser.Document.eventlisteners %Is empty?
> hBrowser.Document.Application.registerevent(@testing) %I dont see these events
> hBrowser.Document.Application.ActiveSheet.registerevent(@testing) %I dont see these events
> hBrowser.Document.Application.ActiveWindow.registerevent(@testing) %I dont see these events
> hBrowser.Document.Application.ActiveWorkbook.registerevent(@testing) %I dont see these events
>
> I would like to be able to view events on the excel document that is opened, but for some reason it doesn't look like they're properly registered. Anyone have any ideas?

Unfortunately all of the "children" of the control (ie: Document, Document.Application, ets) are Interfaces and MATLAB does not support interface events.

You can see this by using the class function

class(hBrowser)

ans =

COM.Shell_Explorer_2

% ie this is a COM object


class(hBrowser.Document)

ans =

Interface.Microsoft_HTML_Object_Library.DispHTMLDocument

% while this is an Interface object

Hope this Helps

Donn

Subject: Events from document opened with Shell.Explorer

From: Yair Altman

Date: 11 Mar, 2011 09:20:05

Message: 3 of 3

> > hBrowser = actxcontrol ('Shell.Explorer.2', [0 0 780 420]); %Also tried 'Shell.Explorer'
> > hBrowser.registerevent(@testing) %I see these events
> > hBrowser.eventlisteners %Lists all of the events that were registered
> > hBrowser.Document.registerevent(@testing) %I dont see these events
> > hBrowser.Document.eventlisteners %Is empty?
[snip]

> Unfortunately all of the "children" of the control (ie: Document, Document.Application, ets) are Interfaces and MATLAB does not support interface events.


Perhaps it is more accurate to say that Matlab does not support *user-generated* events - some COM interfaces do have events that you can possibly use. For example:

>> hBrowser.Document.events
SelectionChanged = void SelectionChanged()
EnumDone = void EnumDone()
VerbInvoked = void VerbInvoked()
DefaultVerbInvoked = void DefaultVerbInvoked()
BeginDrag = void BeginDrag()

>> hBrowser.Application.events
BeforeNavigate = void BeforeNavigate(string URL, int32 Flags, string TargetFrameName, Variant PostData, string Headers, bool Cancel)
NavigateComplete = void NavigateComplete(string URL)
StatusTextChange = void StatusTextChange(string Text)
ProgressChange = void ProgressChange(int32 Progress, int32 ProgressMax)
DownloadComplete = void DownloadComplete()
CommandStateChange = void CommandStateChange(int32 Command, bool Enable)
DownloadBegin = void DownloadBegin()
NewWindow = void NewWindow(string URL, int32 Flags, string TargetFrameName, Variant PostData, string Headers, bool Processed)
TitleChange = void TitleChange(string Text)
FrameBeforeNavigate = void FrameBeforeNavigate(string URL, int32 Flags, string TargetFrameName, Variant PostData, string Headers, bool Cancel)
FrameNavigateComplete = void FrameNavigateComplete(string URL)
FrameNewWindow = void FrameNewWindow(string URL, int32 Flags, string TargetFrameName, Variant PostData, string Headers, bool Processed)
Quit = void Quit(bool Cancel)
WindowMove = void WindowMove()
WindowResize = void WindowResize()
WindowActivate = void WindowActivate()
PropertyChange = void PropertyChange(string Property)

Yair Altman
http://UndocumentedMatlab.com

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us