Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Problem getting excel to work in Visual Studio (C#)

Hi,

I'm trying to develop en application in Vusial Studio (C#)
towards excel. But I cannot get anything to work. Trying
to find a object (a command button) or even outputting
text to cell (rng.Value2("Hello world");) throws an
exception.

The exception have the message: HRESULT: 0x800A03EC.

What is wrong? I cannot find any information out there
that helps.

//Harald Antonsen :)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Problem getting excel to work in Visual Studio (C#)

I don't know too much abaut C#, but...
rng.Value2("Hello world")
Range is an object, for example: multiple of cells.

I'll show, how to do this from VB using OLE:

Sub Test()
Dim ExApp as Excel.Application
Dim ExWbk as Workbook
Dim ExWsh as WorkSheet
Dim rng as Excel.Range

Set ExApp = CreateObject("Excel.Application") 'open Excel
Set ExWbk = ExApp.Workbooks.Open "path" 'open Workbook
Set ExWsh = ExWbk.Worksheets("sheet1") 'whichone sheet
Set rng = ExWsh.Range("A1") 'cell, for example A1

rng.Value = "Hello World!"

Set rng = Nothing 'free memory
Set ExWsh = Nothing
ExWbk.Close SaveChanges:=False
Set ExWbk = Nothing
ExApp.Quit SaveChanges:=False
Set ExApp = Nothing

End Sub


I hope, it was helpfull...

-----Original Message-----
Hi,

I'm trying to develop en application in Vusial Studio

(C#)
towards excel. But I cannot get anything to work. Trying
to find a object (a command button) or even outputting
text to cell (rng.Value2("Hello world");) throws an
exception.

The exception have the message: HRESULT: 0x800A03EC.

What is wrong? I cannot find any information out there
that helps.

//Harald Antonsen :)
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Problem getting excel to work in Visual Studio (C#)

Sorry, typo in my example code. Should ofcource be
rnd.Value2 = "Hello World";

Code still don't work! :)

//Harald Antonsen

-----Original Message-----
Hi,

I'm trying to develop en application in Vusial Studio

(C#)
towards excel. But I cannot get anything to work. Trying
to find a object (a command button) or even outputting
text to cell (rng.Value2("Hello world");) throws an
exception.

The exception have the message: HRESULT: 0x800A03EC.

What is wrong? I cannot find any information out there
that helps.

//Harald Antonsen :)
.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Problem getting excel to work in Visual Studio (C#)

Oooops, my typo in the post. should be rnd.Value2 = "Hello
World";

Problem sill exists.

//Harald Antonsen

-----Original Message-----
I don't know too much abaut C#, but...
rng.Value2("Hello world")
Range is an object, for example: multiple of cells.

I'll show, how to do this from VB using OLE:

Sub Test()
Dim ExApp as Excel.Application
Dim ExWbk as Workbook
Dim ExWsh as WorkSheet
Dim rng as Excel.Range

Set ExApp = CreateObject("Excel.Application") 'open Excel
Set ExWbk = ExApp.Workbooks.Open "path" 'open Workbook
Set ExWsh = ExWbk.Worksheets("sheet1") 'whichone sheet
Set rng = ExWsh.Range("A1") 'cell, for example A1

rng.Value = "Hello World!"

Set rng = Nothing 'free memory
Set ExWsh = Nothing
ExWbk.Close SaveChanges:=False
Set ExWbk = Nothing
ExApp.Quit SaveChanges:=False
Set ExApp = Nothing

End Sub


I hope, it was helpfull...

-----Original Message-----
Hi,

I'm trying to develop en application in Vusial Studio

(C#)
towards excel. But I cannot get anything to work. Trying
to find a object (a command button) or even outputting
text to cell (rng.Value2("Hello world");) throws an
exception.

The exception have the message: HRESULT: 0x800A03EC.

What is wrong? I cannot find any information out there
that helps.

//Harald Antonsen :)
.

.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default Problem getting excel to work in Visual Studio (C#)

Hi Harald,

I'm trying to develop en application in Vusial Studio (C#)
towards excel. But I cannot get anything to work. Trying
to find a object (a command button) or even outputting
text to cell (rng.Value2("Hello world");) throws an
exception.

The exception have the message: HRESULT: 0x800A03EC.

What is wrong? I cannot find any information out there
that helps.


If you go to msdn.microsoft.com and search for 'Visual Studio Tools for
Office', you should find lots of c# examples that might help.

Regards

Stephen Bullen
Microsoft MVP - Excel
www.BMSLtd.co.uk



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 459
Default Problem getting excel to work in Visual Studio (C#)

Just adding to what Stephen has said, I don't think you can hook a
commandbutton's events in .NET without Visual Studio Tools for Office.
VSTO provides many accessor methods (e.g. get_Range) to deal with the
problem of C# not supporting parameterized properties (that why you're
using Value2, right?)

If you don't have VSTO available to you, you'll probably want to start
using a lot of hyperlinks because the SheetFollowHyperlink is the most
useful event! See that following article MSDN for lots of non-VSTO C#
code:

Understanding the Excel Object Model from a .NET Developer's
Perspective:

http://msdn.microsoft.com/vstudio/of...l/excelobj.asp

--

Stephen Bullen wrote in message ...
Hi Harald,

I'm trying to develop en application in Vusial Studio (C#)
towards excel. But I cannot get anything to work. Trying
to find a object (a command button) or even outputting
text to cell (rng.Value2("Hello world");) throws an
exception.

The exception have the message: HRESULT: 0x800A03EC.

What is wrong? I cannot find any information out there
that helps.


If you go to msdn.microsoft.com and search for 'Visual Studio Tools for
Office', you should find lots of c# examples that might help.

Regards

Stephen Bullen
Microsoft MVP - Excel
www.BMSLtd.co.uk

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is Visual Basic the same as Visual Studio 2008? Mike Stewart Excel Worksheet Functions 5 January 11th 09 04:58 PM
Excel rejects XSD from Visual Studio DataSet Designer rico Excel Discussion (Misc queries) 0 September 16th 08 09:35 PM
get Excel array values in Visual Studio VB Noel Rietman Excel Discussion (Misc queries) 1 October 21st 06 10:16 AM
changing the visual basic in office 2003 to visual studio net bigdaddy3 Excel Discussion (Misc queries) 1 September 13th 05 10:57 AM
Visual Studio Tools for Office- Excel Manoj[_3_] Excel Programming 1 October 14th 03 02:46 PM


All times are GMT +1. The time now is 12:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"