C
calvinX
Sorry about the cross-post but I am in a bit of a bind.
I am developing an Add-in for Visio 2002 using VS.NET and I am having
trouble getting a reference to an excel worksheet object that exists on the
page. Here is the code I am having a problem with (doc is declared as
Microsoft.Office.Interop.Visio.Document in the function parameters):
sel = doc.Application.ActiveWindow.Selection '>> Works
obj = sel.Item(1).Object '>> Works
xlSheet = CType(obj, Microsoft.Office.Interop.Excel.WorkSheet) '>>
Throws "Specified Cast is not Valid" exception
MsgBox("Got sheet = " & xlSheet.Name) '>> never gets here
I tried casting to a Workbook object but this did not work either. How can
I get my worksheet object out of the obj variable?
Thanks
Calvin
I am developing an Add-in for Visio 2002 using VS.NET and I am having
trouble getting a reference to an excel worksheet object that exists on the
page. Here is the code I am having a problem with (doc is declared as
Microsoft.Office.Interop.Visio.Document in the function parameters):
sel = doc.Application.ActiveWindow.Selection '>> Works
obj = sel.Item(1).Object '>> Works
xlSheet = CType(obj, Microsoft.Office.Interop.Excel.WorkSheet) '>>
Throws "Specified Cast is not Valid" exception
MsgBox("Got sheet = " & xlSheet.Name) '>> never gets here
I tried casting to a Workbook object but this did not work either. How can
I get my worksheet object out of the obj variable?
Thanks
Calvin