Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi Cindy,

 

I am creating a simple VB.Net Excel Addin, where in I am trying to Trap the Selection Type. I am trying the function after clicking a button in the Ribbon. And I am using Ribbon Designer for this. Not sure if it does create any difference. The Ribbon designer has the following Event handler:

 


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs) Handles Button1.Click
       'MsgBox("Button Clicked", MsgBoxStyle.Critical, "Success!!")
       Dim app As Application = Globals.ThisAddIn.Application

       Dim selType As String

       Dim typ As Type

       Dim strName As String
       strName = ""
       Dim sels As Object
       Dim proxy As XLAppProxy

       proxy = XLAppProxy.GetApplication()
       sels = TryCast(app.Selection, Object)

       Try
           selType = Information.TypeName(app.Selection)
       Catch ex As Exception
           MsgBox(ex.Message, MsgBoxStyle.Critical, "Hello")
       End Try
   End Sub

 

Now, when the line "selType = Information.TypeName(app.Selection)" is executed, I get the following exception : "The interface does not support late bound calls since it does not derive from IDispatch." The type of exception is System.Reflection.TargetInvocationException.

 

Hope to get a reply soon.

 

Thanks,

Vikas

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...