LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.vsnet.vstools.office,microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Progamatically Formating Cells within VSTO for Excel Application Development using C#

Hi,

I am developing an Excel application using VSTO with C#. Application
consists of multiple sheets and very freuquently requires setting the
formalling style for cell programatically. In doing do I have come across
two main issues:
1. If I have any of the sheet protected (even with option selected "To Allow
Formating Cells") within the workbook, the code which sets the cell style
thorws exception suggesting one cannnot do this operation on protected
sheet.
2. So to move on I made sure all the sheets are unprotected. Now I am able
to set the style on Named Range which are made up of one cell. However when
a name range consists of mulitple rows and columns and I want to set the
style of cells in one of the column of this range, it does not see to take
the new style in effect.

Here is my code snipet:
//I first obtain the style string
String strStyle = Globals.ThisWorkbook.GetFormatString(strMsrName);

//set the style of the second column cells of MsrDetails range, which
consists of 10 rows and 2 columns

//This code does not reflect any change in style I am applying here..

for (int k = 1; k <= this.MsrDetails.Rows.Count; k++)

{

Excel.Range cell = ((Excel.Range)this.MsrDetails.Cells[k, 2]);

((Excel.Style)(cell.Style)).NumberFormat = strStyle;

}

//However this works just fine, where ToBe value is a range made up of one
cell only.

((Excel.Style)this.ToBe.Style).NumberFormat = strStyle;




I will really appreciate you input. Thanks so much.

Regards

-Sharad


 
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
rates for Excel application development consultants Dave F Excel Discussion (Misc queries) 1 February 8th 07 09:33 PM
Excel Application Development Costs - Need Advice TheRobsterUK Excel Discussion (Misc queries) 2 June 3rd 05 08:23 PM
EXCEL, VSTO: Fastest way to access multiple cells Peter T Excel Programming 0 June 1st 05 02:51 PM
EXCEL, VSTO: Fastest way to access multiple cells Alan Excel Discussion (Misc queries) 1 June 1st 05 02:45 PM
Hiding Rows progamatically David Bateman Excel Programming 1 January 19th 05 05:59 PM


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

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

About Us

"It's about Microsoft Excel"