Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default ModifyAppliesToRange

I've posted this in a few places, but am not getting any traction, so here is
another post. =D

I'm attempting to create a relatively simple Excel Add In. I have the
basics working, but now I'm attempting to iterate through the existing Format
Conditions and show a message box with the AppliesTo range. All I ever get,
sadly, is the _ComObject. In VBA, I could do AppliesTo.Address to see the
range, but that doesn't seem to be available in C# VSTO 2008. I did convert
this add-in to VS2010, and the AppliesTo.Address property has re-appeared,
but now Excel consistently crashes every time.

What I really want to do is fix the Applies To range, after a data refresh,
but this tends to consistently crash Excel. What's odd, though, is that the
code below doesn't crash it immediately, rather I get two message boxes, and
then it crashes. Of course, I'm not saving the work book, so I have no idea,
if the code is really working or not.

At this point, I'm pretty frustrated because there doesn't really seem to be
a lot of documentation, and the method works a couple of times before bombing
Excel and forcing an error report. If anyone can provide some insight and/or
links, I would be forever in your debt.

private void btnUpdateRange_Click(object sender,
RibbonControlEventArgs e)
{
if (curRange.FormatConditions.Count == 0)
{
MessageBox.Show("No Conditional Formats set up in current
sheet", "No Formats", MessageBoxButtons.OK);
}

else
{
foreach (xls.FormatCondition oFc in curRange.FormatConditions)
{
//MessageBox.Show(oFc.AppliesTo.Value2.ToString(),
"Applies to Range", MessageBoxButtons.OK);
oFc.ModifyAppliesToRange(curRange);
}
}
}
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
ModifyAppliesToRange question mikelee101 Excel Programming 0 August 17th 09 07:30 PM


All times are GMT +1. The time now is 07:13 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"