Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel, C#, and IE

I'm not sure if this is the appropriate group to post to for this question,
since the question sort of crosses some of the group descriptions, but I'm
going to start here...

I've built a C# application for a customer that hosts the
AxSHDocVw.AxWebBrowser control. Using that control, I navigate to a local
Excel document as described in this knowledgebase article:

http://support.microsoft.com/kb/304662/EN-US/

The whole purpose of this is to accomplish what we used to do when we'd
embed an Excel document into a form in the 6.0 days.... this became a bit
more involved with .Net, since it appears we have to use the web browser
control as a kind of proxy in the middle between the host application and the
Excel active document. Anyway, the Excel document in question has embedded
buttons and other UI controls in the cells of the document itself.

My question is, how in the world do I bubble up the events of these controls
to the host application? I've tried everything I can think of, and nothing
seems to bubble up. Is this even possible?

Thanks!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 205
Default Excel, C#, and IE

Hi Calphool,

My question is, how in the world do I bubble up the events of these controls
to the host application? I've tried everything I can think of, and nothing
seems to bubble up. Is this even possible?


Good question. The events of the controls inside the workbook won't bubble up
by themselves, but it might be possible to hook their events after the workbook
has been loaded. I haven't tried it from .NET, but you might be able to
reference the Excel PIAs in some client-side code, drill down via the
WebBrowser control to get to the Workbook object and the individual controls
within it and hook them up to some event handlers declared at the top level.

I tested it using VB6 with a Web Browser control on a form, references to the
Excel and Microsoft Forms object libraries and the following code behind the
form:

Dim WithEvents mlblLabel As MSForms.Label

Private Sub Command1_Click()
Dim wkb As Excel.Workbook
Me.WebBrowser1.Navigate "c:\book3.xls"
Set wkb = Me.WebBrowser1.Document
Set mlblLabel = wkb.Worksheets(1).Shapes(1).OLEFormat.Object.Objec t
End Sub

Private Sub mlblLabel_Click()
MsgBox "Clicked!"
End Sub


Where book3.xls is an Excel workbook with a single label (from the Control
Toolbox) on sheet 1. When I clicked the label on the worksheet inside the
browser control, the "Clicked!" message popped up!

Regards

Stephen Bullen
Microsoft MVP - Excel
www.oaltd.co.uk


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 03:33 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"