VSTO2005 - HResult Exception obtaining Range Object

J

Jay Pondy

When placed in ThisWorkbook_StartUp the following code yields an HResult
Exception:

Dim oRange As Microsoft.Office.Interop.Excel.Range
oRange = Globals.Sheet1.Range("$A$1")

What am I doing wrong?

(I will need the range object as a parameter for the
Globals.Sheet1.Controls.AddListObject method.)
 
J

Jay Pondy

Passing as single cell arguement to the Range method gives the error whereas
passing two cells fixes the problem. I believe this is a bug in VSTO2005.

Error: oRange = Globals.Sheet1.Range("A1")
Works: oRange = Globals.Sheet1.Range("A1", "A1")

The documentation contains an example that gives the same error until the
fix above is applied:

Dim textInCell As Microsoft.Office.Tools.Excel.NamedRange
textInCell = Me.Controls.AddNamedRange( Me.Range("A1"), "cellText")

should be: Me.Range("A1", "A1")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top