Vikasbhandari2 Posted March 31, 2009 Posted March 31, 2009 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 Quote
Vikasbhandari2 Posted April 3, 2009 Author Posted April 3, 2009 see the following link for the solution. Thanks! http://excelnoob.blogspot.com/2009/04/problem-in-using-informationtypename.html Quote
Recommended Posts