Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default SpecialCells method of Range class failed

Hi,

I use Range.SpecialCells method (C#, Excel 2003) to filter visible cells. It
works fine, but if cursor is in Formula Bar it rises an exception
"System.Runtime.InteropServices.COMException (0x800A03EC): SpecialCells
method of Range class failed".
Can I force Range.SpecialCells to work in this situation? Or can I, at
least, determine that cursor is in Formula Bar?

In some cases (including described above) Excel's Visual Basic Editor
becomes disabled. It seems, it was made intentionally to prevent Excel
automation. Can anybody explain this situation? And how can I treat it in C#.

Thank you in advance!
Sergei.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default SpecialCells method of Range class failed

Use Activate to select a worksheet and Select to move the cursor to the
worksheet.

Sheets("Sheet1").Activate
Range("A1").Select

"Sergei Emelyanenkov" wrote:

Hi,

I use Range.SpecialCells method (C#, Excel 2003) to filter visible cells. It
works fine, but if cursor is in Formula Bar it rises an exception
"System.Runtime.InteropServices.COMException (0x800A03EC): SpecialCells
method of Range class failed".
Can I force Range.SpecialCells to work in this situation? Or can I, at
least, determine that cursor is in Formula Bar?

In some cases (including described above) Excel's Visual Basic Editor
becomes disabled. It seems, it was made intentionally to prevent Excel
automation. Can anybody explain this situation? And how can I treat it in C#.

Thank you in advance!
Sergei.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default SpecialCells method of Range class failed

I tried to activate worksheet and select the range, but it doesn't help.
Exception still arises.
I can't work through this issue with VBA, because VBA Editor disabled (in my
instance of Excel 2003) when cursor is in Formula Bar. A part of C# code I've
used:

using Excel = Microsoft.Office.Interop.Excel;

Excel.Application objExcelApp = GetExcelApp(); // Custom function to
receive Excel application object.
Excel.Range rng =(Excel.Range)objExcelApp.Selection; // Get selected
cells. Works fine, even through cursor is in Formula Bar.
rng.Worksheet.Activate();
rng.Select();
Excel.Range objRngVisible =
rng.SpecialCells(Excel.XlCellType.xlCellTypeVisibl e, Type.Missing); // Get
only visible cells from selection. Exception here :(


"Joel" wrote:

Use Activate to select a worksheet and Select to move the cursor to the
worksheet.

Sheets("Sheet1").Activate
Range("A1").Select

"Sergei Emelyanenkov" wrote:

Hi,

I use Range.SpecialCells method (C#, Excel 2003) to filter visible cells. It
works fine, but if cursor is in Formula Bar it rises an exception
"System.Runtime.InteropServices.COMException (0x800A03EC): SpecialCells
method of Range class failed".
Can I force Range.SpecialCells to work in this situation? Or can I, at
least, determine that cursor is in Formula Bar?

In some cases (including described above) Excel's Visual Basic Editor
becomes disabled. It seems, it was made intentionally to prevent Excel
automation. Can anybody explain this situation? And how can I treat it in C#.

Thank you in advance!
Sergei.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default SpecialCells method of Range class failed

You need to specify a worksheet and a range of cells

for example from excel VBA
set rng = activesheet.cells
or
set rng = activesheet.column("A")

Normally from another application you create a sheet. this would be the
macro from Microsoftword for creating ax excel object

Set ExcelSheet = CreateObject("Excel.Sheet")

You didn't post the functions that creates the excel object so I don't know
exactly what "rng" is set to.




"Sergei Emelyanenkov" wrote:

I tried to activate worksheet and select the range, but it doesn't help.
Exception still arises.
I can't work through this issue with VBA, because VBA Editor disabled (in my
instance of Excel 2003) when cursor is in Formula Bar. A part of C# code I've
used:

using Excel = Microsoft.Office.Interop.Excel;

Excel.Application objExcelApp = GetExcelApp(); // Custom function to
receive Excel application object.
Excel.Range rng =(Excel.Range)objExcelApp.Selection; // Get selected
cells. Works fine, even through cursor is in Formula Bar.
rng.Worksheet.Activate();
rng.Select();
Excel.Range objRngVisible =
rng.SpecialCells(Excel.XlCellType.xlCellTypeVisibl e, Type.Missing); // Get
only visible cells from selection. Exception here :(


"Joel" wrote:

Use Activate to select a worksheet and Select to move the cursor to the
worksheet.

Sheets("Sheet1").Activate
Range("A1").Select

"Sergei Emelyanenkov" wrote:

Hi,

I use Range.SpecialCells method (C#, Excel 2003) to filter visible cells. It
works fine, but if cursor is in Formula Bar it rises an exception
"System.Runtime.InteropServices.COMException (0x800A03EC): SpecialCells
method of Range class failed".
Can I force Range.SpecialCells to work in this situation? Or can I, at
least, determine that cursor is in Formula Bar?

In some cases (including described above) Excel's Visual Basic Editor
becomes disabled. It seems, it was made intentionally to prevent Excel
automation. Can anybody explain this situation? And how can I treat it in C#.

Thank you in advance!
Sergei.

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
Select method of Range class failed Istvan Excel Programming 17 April 11th 08 07:05 AM
Delete method of Range class failed dan_coder Excel Programming 1 July 24th 06 10:16 AM
AutoFilter method of Range class failed blopreste3180 Excel Programming 1 January 17th 06 10:40 PM
Autofilter method of range class failed Terry K Excel Programming 5 October 18th 05 03:09 AM
Autofill method of Range class failed JJ \(UK\)[_2_] Excel Programming 2 August 14th 05 07:46 PM


All times are GMT +1. The time now is 08:23 PM.

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"