Link to home
Create AccountLog in
Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

VSTO Excel Add-In problem reading Excel cells

Hi

If I create a fresh Excel 2007 Add-In project in Visual Studio 2010 and create a Windows form,
what is the simplest way to read cell values from the Active Excel workbook?
Do I need to add any references or imports?
Avatar of ScriptAddict
ScriptAddict
Flag of United States of America image

Activeworkbook.worksheets("Sheet1").range("A1").Value

or

workbooks("Example.xlsx").Worksheets("Sheet1").Range("A1").Value
Avatar of Murray Brown

ASKER

I get the error 'Activeworkbook' is not declared. It may be inaccessible due to its protection level
You may need to open the workbook first

workbooks("yourworkbook.xlsx").open
Workbooks("yourworkbook.xlsx").activiate

Then I can't see how activeworkbook could give you any problems.
No that is not it.I thought that I had to use Microsoft.Office.Interop.... or Globals..... but can't work out the code
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Excellent. Thanks