I do it all the time in VB.Net just the way I showed in my post.
I'm not a C# guy, but you should be able to do something like:
In Excel, the Worksheets collection is the subset of Sheets collection
that
is made up of worksheets (but not macro or chart sheets). But since I
think
OWC only supports worksheets, I would think they are synonymous for
your
purposes.
On 18 Apr., 01:57, "Alvin Bruney [MVP]" <some guy without an email
address> wrote:
If memory serves me correctly, it's activesheet object that you
want
to
index.
--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
OWC Black book on Amazon andwww.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley
all I want to do is to select one specific sheet in my
OWC11.AxSpreadSheet component. Let's assume there are four
sheets,
the
cursor is on "Sheet1" and I want to bring the content of "Sheet3"
in
front.
My axSpreadSheet component is placed on a Windows Form, the code
is
written in C#. Tried the following:
axSpreadSheet.Worksheets[1] does not bring up "Select" in
IntelliSense.
axSpreadSheet.Worksheets(1) does not bring up anything in
IntelliSense.
Any hints are highly appreciated
Stocki- Zitierten Text ausblenden -
- Zitierten Text anzeigen -
... what I have found so far is something like
ActiveSheet.Next.Select(object Replace) ... but what is "object
Replace" and how can I define it?
I started another approach with the "Sheets"-object. The following
piece of code can be compiled, but it gives me an error during
runtime:
object sheetNo = 2 ;
axsprPlanung.Sheets.Select(sheetNo) ;
Error message: "Exception from HRESULT: 0xE0040046"
Cheers
Stocki- Zitierten Text ausblenden -
- Zitierten Text anzeigen -
Thanks for your response. Unfortunatelly this was what I tried in the
first run, without any luck as you can see from my first post.
This starts to get a nightmare. Since a couple of days I am trying to
get this to work. Next approch was something like:
object myself = false ;
((OWC.Worksheet) this.axsprPlanung.Worksheets[1]).Select(ref
myself ) ;
which also throws an error when running.
There must be a way to select a worksheet programmatically ...
Stocki- Zitierten Text ausblenden -
- Zitierten Text anzeigen -
Hi Josh, Hi Alvin,
finally I got the solution, which shows that VB.Net and C# are
completly different in some cases. As already mentioned in one of the
earlier postings a "Select()" always needs some kind of param (in C#,
in VB.Net it obviously doesn't), which is defined with "ref object
Replace". This param has to be a "Missing" value which is defined as
"object ms = System.Reflection.Missing.Value ;". This is one issue.
Secondly, you first have to cast your *current* spreadsheet into an
OWC.Worksheet, before you are able to access the Select-method.
The solution is:
object ms = System.Reflection.Missing.Value ;
((OWC.Worksheet) this.axsprPlanung.Worksheets[2]).Select( ref ms ) ;
This does nothing but selecting the second sheet in axsprPlanung.
Amazing, isn't it?
I thought it might be a good idea to share this with you, just in case
somebody out there has come across the same problem and is looking for
a solution.
Cheers
Stocki