Strange errors reading properties of a FormatCondition












0















I have a FormatCondition, cf1. I do the following:



Dim WS As Worksheet
Dim fcs As FormatConditions
Dim cf1 As FormatCondition
Dim b1 As Border

Set WS = ActiveSheet
Set fcs = WS.Cells.FormatConditions
Set cf1 = fcs.item(1)
Set b1 = cf1.Borders.item(xlEdgeBottom)

Dim ls As XlLineStyle
ls = b1.LineStyle


If I then try to read the b1.LineStyle in the Immediate window or assign it to a variable (per the last line above) I get




Error 1004: 'Unable to get the LineStyle property of the Border class'




(It's the same error string in the watch list but without the error number)



I get something similar for b1.Weight



This happens whether there is a line on the border of the Conditional Format or not, which surely cannot be right. If there is indeed no Line Style for that format I would think that LineStyle should then be xlLineStyleNone, and if there is a Line Style then surely it should be readable?



Does anyone know what is going on and how I can fix it?



Please note: I've looked at the borders found and some of the other Border properties seem right (ie the Color=0 and ColorIndex is either -4142 or -4105). ThemeColor and TintAndShade are Null, and Creator is xlCreatorCode.



I found some references to issues in setting LineStyle and Weight, and those said that the sheet was locked. This is not the case here as far as I know.





ADDITION:
I sometimes get a different error when trying to read b1.ThemeColor as well.




'Application-defined or object-defined error'




in the watch list, or




Run-time error 5: 'Invalid procedure call or argument'




when reading in the Immediate window. Other times it is just Null





FURTHER ADDITION:
For cf1.Interior.InvertIfNegative I get




'Application-defined or object-defined error'




in the watch list, or




Run-time error 1004: 'Application-defined or object-defined error'




when trying to read in the Immediate window.



There may be others I haven't found yet.










share|improve this question

























  • Can you provide more code please? How is cf1 defined and initialized? Can you provide a Minimal, Complete, and Verifiable example to reproduce the issue?

    – Pᴇʜ
    Nov 26 '18 at 8:26













  • @Pᴇʜ - Done, sorry. I've checked, and the FormatCondition certainly seems to be valid, it holds values that I would expect in most of the properties. You will need to create an excel sheet with an appropriate Conditional Formatting rule to test.

    – James Carlyle-Clarke
    Nov 26 '18 at 8:50













  • The rules I am using are using a formula, eg =NOT(ISNUMBER(C9)), and impose a cell fill colour and sometimes a border on the bottom of the cell, and cover a range of cells, eg $C$8:$C$39

    – James Carlyle-Clarke
    Nov 26 '18 at 8:59











  • Use the DisplayFormat of the Cell instead of going through the formatconditions

    – EvR
    Nov 26 '18 at 13:19











  • Thanks @EvR but I actually need the FormatConditions

    – James Carlyle-Clarke
    Nov 27 '18 at 10:00
















0















I have a FormatCondition, cf1. I do the following:



Dim WS As Worksheet
Dim fcs As FormatConditions
Dim cf1 As FormatCondition
Dim b1 As Border

Set WS = ActiveSheet
Set fcs = WS.Cells.FormatConditions
Set cf1 = fcs.item(1)
Set b1 = cf1.Borders.item(xlEdgeBottom)

Dim ls As XlLineStyle
ls = b1.LineStyle


If I then try to read the b1.LineStyle in the Immediate window or assign it to a variable (per the last line above) I get




Error 1004: 'Unable to get the LineStyle property of the Border class'




(It's the same error string in the watch list but without the error number)



I get something similar for b1.Weight



This happens whether there is a line on the border of the Conditional Format or not, which surely cannot be right. If there is indeed no Line Style for that format I would think that LineStyle should then be xlLineStyleNone, and if there is a Line Style then surely it should be readable?



Does anyone know what is going on and how I can fix it?



Please note: I've looked at the borders found and some of the other Border properties seem right (ie the Color=0 and ColorIndex is either -4142 or -4105). ThemeColor and TintAndShade are Null, and Creator is xlCreatorCode.



I found some references to issues in setting LineStyle and Weight, and those said that the sheet was locked. This is not the case here as far as I know.





ADDITION:
I sometimes get a different error when trying to read b1.ThemeColor as well.




'Application-defined or object-defined error'




in the watch list, or




Run-time error 5: 'Invalid procedure call or argument'




when reading in the Immediate window. Other times it is just Null





FURTHER ADDITION:
For cf1.Interior.InvertIfNegative I get




'Application-defined or object-defined error'




in the watch list, or




Run-time error 1004: 'Application-defined or object-defined error'




when trying to read in the Immediate window.



There may be others I haven't found yet.










share|improve this question

























  • Can you provide more code please? How is cf1 defined and initialized? Can you provide a Minimal, Complete, and Verifiable example to reproduce the issue?

    – Pᴇʜ
    Nov 26 '18 at 8:26













  • @Pᴇʜ - Done, sorry. I've checked, and the FormatCondition certainly seems to be valid, it holds values that I would expect in most of the properties. You will need to create an excel sheet with an appropriate Conditional Formatting rule to test.

    – James Carlyle-Clarke
    Nov 26 '18 at 8:50













  • The rules I am using are using a formula, eg =NOT(ISNUMBER(C9)), and impose a cell fill colour and sometimes a border on the bottom of the cell, and cover a range of cells, eg $C$8:$C$39

    – James Carlyle-Clarke
    Nov 26 '18 at 8:59











  • Use the DisplayFormat of the Cell instead of going through the formatconditions

    – EvR
    Nov 26 '18 at 13:19











  • Thanks @EvR but I actually need the FormatConditions

    – James Carlyle-Clarke
    Nov 27 '18 at 10:00














0












0








0


0






I have a FormatCondition, cf1. I do the following:



Dim WS As Worksheet
Dim fcs As FormatConditions
Dim cf1 As FormatCondition
Dim b1 As Border

Set WS = ActiveSheet
Set fcs = WS.Cells.FormatConditions
Set cf1 = fcs.item(1)
Set b1 = cf1.Borders.item(xlEdgeBottom)

Dim ls As XlLineStyle
ls = b1.LineStyle


If I then try to read the b1.LineStyle in the Immediate window or assign it to a variable (per the last line above) I get




Error 1004: 'Unable to get the LineStyle property of the Border class'




(It's the same error string in the watch list but without the error number)



I get something similar for b1.Weight



This happens whether there is a line on the border of the Conditional Format or not, which surely cannot be right. If there is indeed no Line Style for that format I would think that LineStyle should then be xlLineStyleNone, and if there is a Line Style then surely it should be readable?



Does anyone know what is going on and how I can fix it?



Please note: I've looked at the borders found and some of the other Border properties seem right (ie the Color=0 and ColorIndex is either -4142 or -4105). ThemeColor and TintAndShade are Null, and Creator is xlCreatorCode.



I found some references to issues in setting LineStyle and Weight, and those said that the sheet was locked. This is not the case here as far as I know.





ADDITION:
I sometimes get a different error when trying to read b1.ThemeColor as well.




'Application-defined or object-defined error'




in the watch list, or




Run-time error 5: 'Invalid procedure call or argument'




when reading in the Immediate window. Other times it is just Null





FURTHER ADDITION:
For cf1.Interior.InvertIfNegative I get




'Application-defined or object-defined error'




in the watch list, or




Run-time error 1004: 'Application-defined or object-defined error'




when trying to read in the Immediate window.



There may be others I haven't found yet.










share|improve this question
















I have a FormatCondition, cf1. I do the following:



Dim WS As Worksheet
Dim fcs As FormatConditions
Dim cf1 As FormatCondition
Dim b1 As Border

Set WS = ActiveSheet
Set fcs = WS.Cells.FormatConditions
Set cf1 = fcs.item(1)
Set b1 = cf1.Borders.item(xlEdgeBottom)

Dim ls As XlLineStyle
ls = b1.LineStyle


If I then try to read the b1.LineStyle in the Immediate window or assign it to a variable (per the last line above) I get




Error 1004: 'Unable to get the LineStyle property of the Border class'




(It's the same error string in the watch list but without the error number)



I get something similar for b1.Weight



This happens whether there is a line on the border of the Conditional Format or not, which surely cannot be right. If there is indeed no Line Style for that format I would think that LineStyle should then be xlLineStyleNone, and if there is a Line Style then surely it should be readable?



Does anyone know what is going on and how I can fix it?



Please note: I've looked at the borders found and some of the other Border properties seem right (ie the Color=0 and ColorIndex is either -4142 or -4105). ThemeColor and TintAndShade are Null, and Creator is xlCreatorCode.



I found some references to issues in setting LineStyle and Weight, and those said that the sheet was locked. This is not the case here as far as I know.





ADDITION:
I sometimes get a different error when trying to read b1.ThemeColor as well.




'Application-defined or object-defined error'




in the watch list, or




Run-time error 5: 'Invalid procedure call or argument'




when reading in the Immediate window. Other times it is just Null





FURTHER ADDITION:
For cf1.Interior.InvertIfNegative I get




'Application-defined or object-defined error'




in the watch list, or




Run-time error 1004: 'Application-defined or object-defined error'




when trying to read in the Immediate window.



There may be others I haven't found yet.







excel vba






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 26 '18 at 8:49







James Carlyle-Clarke

















asked Nov 26 '18 at 3:00









James Carlyle-ClarkeJames Carlyle-Clarke

451415




451415













  • Can you provide more code please? How is cf1 defined and initialized? Can you provide a Minimal, Complete, and Verifiable example to reproduce the issue?

    – Pᴇʜ
    Nov 26 '18 at 8:26













  • @Pᴇʜ - Done, sorry. I've checked, and the FormatCondition certainly seems to be valid, it holds values that I would expect in most of the properties. You will need to create an excel sheet with an appropriate Conditional Formatting rule to test.

    – James Carlyle-Clarke
    Nov 26 '18 at 8:50













  • The rules I am using are using a formula, eg =NOT(ISNUMBER(C9)), and impose a cell fill colour and sometimes a border on the bottom of the cell, and cover a range of cells, eg $C$8:$C$39

    – James Carlyle-Clarke
    Nov 26 '18 at 8:59











  • Use the DisplayFormat of the Cell instead of going through the formatconditions

    – EvR
    Nov 26 '18 at 13:19











  • Thanks @EvR but I actually need the FormatConditions

    – James Carlyle-Clarke
    Nov 27 '18 at 10:00



















  • Can you provide more code please? How is cf1 defined and initialized? Can you provide a Minimal, Complete, and Verifiable example to reproduce the issue?

    – Pᴇʜ
    Nov 26 '18 at 8:26













  • @Pᴇʜ - Done, sorry. I've checked, and the FormatCondition certainly seems to be valid, it holds values that I would expect in most of the properties. You will need to create an excel sheet with an appropriate Conditional Formatting rule to test.

    – James Carlyle-Clarke
    Nov 26 '18 at 8:50













  • The rules I am using are using a formula, eg =NOT(ISNUMBER(C9)), and impose a cell fill colour and sometimes a border on the bottom of the cell, and cover a range of cells, eg $C$8:$C$39

    – James Carlyle-Clarke
    Nov 26 '18 at 8:59











  • Use the DisplayFormat of the Cell instead of going through the formatconditions

    – EvR
    Nov 26 '18 at 13:19











  • Thanks @EvR but I actually need the FormatConditions

    – James Carlyle-Clarke
    Nov 27 '18 at 10:00

















Can you provide more code please? How is cf1 defined and initialized? Can you provide a Minimal, Complete, and Verifiable example to reproduce the issue?

– Pᴇʜ
Nov 26 '18 at 8:26







Can you provide more code please? How is cf1 defined and initialized? Can you provide a Minimal, Complete, and Verifiable example to reproduce the issue?

– Pᴇʜ
Nov 26 '18 at 8:26















@Pᴇʜ - Done, sorry. I've checked, and the FormatCondition certainly seems to be valid, it holds values that I would expect in most of the properties. You will need to create an excel sheet with an appropriate Conditional Formatting rule to test.

– James Carlyle-Clarke
Nov 26 '18 at 8:50







@Pᴇʜ - Done, sorry. I've checked, and the FormatCondition certainly seems to be valid, it holds values that I would expect in most of the properties. You will need to create an excel sheet with an appropriate Conditional Formatting rule to test.

– James Carlyle-Clarke
Nov 26 '18 at 8:50















The rules I am using are using a formula, eg =NOT(ISNUMBER(C9)), and impose a cell fill colour and sometimes a border on the bottom of the cell, and cover a range of cells, eg $C$8:$C$39

– James Carlyle-Clarke
Nov 26 '18 at 8:59





The rules I am using are using a formula, eg =NOT(ISNUMBER(C9)), and impose a cell fill colour and sometimes a border on the bottom of the cell, and cover a range of cells, eg $C$8:$C$39

– James Carlyle-Clarke
Nov 26 '18 at 8:59













Use the DisplayFormat of the Cell instead of going through the formatconditions

– EvR
Nov 26 '18 at 13:19





Use the DisplayFormat of the Cell instead of going through the formatconditions

– EvR
Nov 26 '18 at 13:19













Thanks @EvR but I actually need the FormatConditions

– James Carlyle-Clarke
Nov 27 '18 at 10:00





Thanks @EvR but I actually need the FormatConditions

– James Carlyle-Clarke
Nov 27 '18 at 10:00












1 Answer
1






active

oldest

votes


















1














Actually I can reproduce the issue you describe.



The issue seems to be in Set b1 = cf1.Borders.item(xlEdgeBottom) which is correct according to the documentation FormatCondition.Borders property.



But there seems to be a bug, because the value of xlEdgeBottom is 9 (according to xlBordersIndex enumeration) and if we have a look into the debug of cf1.Borders we see that there is only item 1 … 4 (see image) where 4 seems to be the bottom border.



enter image description here



If no one else has a very good idea here I would say this looks like a Excel bug.



To workaround this you can use eg Set b1 = cf1.Borders.item(4) for the bottom border.





So the solution is …



that Set b1 = cf1.Borders.item(xlBottom) actually worked for me.



Obviously the FormatCondition.Borders doesn't use the correct xlBordersIndex enumeration as it should do but instead uses xlTop, xlLeft, xlBottom, xlRight.



Also refer to FormatConditions border on a single edge.



But still this is not in accordance with the documentation and must be a bug.






share|improve this answer


























  • Honestly, I'd been wondering vaguely about that (as I checked the cf1.Borders.Count value somewhere else) but figured that Excel must just make it work somehow, perhaps by the valid items in the collection starting at an index of 5, or something - I'm not as familiar with the nitty gritty of VBA as I am of c#, and since I could see that at least some of the properties of the Border seemed valid, it never occurred to me that the overall Border might not be.

    – James Carlyle-Clarke
    Nov 26 '18 at 9:19













  • I should mention, if only for others who read this under different circumstances, that it might conceivably only be like this for Borders on Conditional Formatting... normal Borders on a Range might work perfectly normally

    – James Carlyle-Clarke
    Nov 26 '18 at 9:21











  • Obviously the FormatCondition.Borders does not use the right xlBordersIndex enumeration. Instead it uses xlTop, xlLeft, xlBottom, xlRight. But according to the documentation that's wrong and must be a bug.

    – Pᴇʜ
    Nov 26 '18 at 9:22













  • Agreed. This presumably explains the b1.ThemeColor issue too. Any idea on cf1.Interior.InvertIfNegative?

    – James Carlyle-Clarke
    Nov 26 '18 at 9:24






  • 1





    Nah, the b1.ThemeColor issue is still an issue. Only occurs on some of the borders, not all of them. Seems to be where there is a line in the format. And I just found a note on that: Attempting to access a theme color for an object whose color is not currently themed will result in an invalid request run-time error Now I just need to figure out how to tell if a color is themed... :( Thanks for all your help, that was great

    – James Carlyle-Clarke
    Nov 26 '18 at 9:31











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53474250%2fstrange-errors-reading-properties-of-a-formatcondition%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














Actually I can reproduce the issue you describe.



The issue seems to be in Set b1 = cf1.Borders.item(xlEdgeBottom) which is correct according to the documentation FormatCondition.Borders property.



But there seems to be a bug, because the value of xlEdgeBottom is 9 (according to xlBordersIndex enumeration) and if we have a look into the debug of cf1.Borders we see that there is only item 1 … 4 (see image) where 4 seems to be the bottom border.



enter image description here



If no one else has a very good idea here I would say this looks like a Excel bug.



To workaround this you can use eg Set b1 = cf1.Borders.item(4) for the bottom border.





So the solution is …



that Set b1 = cf1.Borders.item(xlBottom) actually worked for me.



Obviously the FormatCondition.Borders doesn't use the correct xlBordersIndex enumeration as it should do but instead uses xlTop, xlLeft, xlBottom, xlRight.



Also refer to FormatConditions border on a single edge.



But still this is not in accordance with the documentation and must be a bug.






share|improve this answer


























  • Honestly, I'd been wondering vaguely about that (as I checked the cf1.Borders.Count value somewhere else) but figured that Excel must just make it work somehow, perhaps by the valid items in the collection starting at an index of 5, or something - I'm not as familiar with the nitty gritty of VBA as I am of c#, and since I could see that at least some of the properties of the Border seemed valid, it never occurred to me that the overall Border might not be.

    – James Carlyle-Clarke
    Nov 26 '18 at 9:19













  • I should mention, if only for others who read this under different circumstances, that it might conceivably only be like this for Borders on Conditional Formatting... normal Borders on a Range might work perfectly normally

    – James Carlyle-Clarke
    Nov 26 '18 at 9:21











  • Obviously the FormatCondition.Borders does not use the right xlBordersIndex enumeration. Instead it uses xlTop, xlLeft, xlBottom, xlRight. But according to the documentation that's wrong and must be a bug.

    – Pᴇʜ
    Nov 26 '18 at 9:22













  • Agreed. This presumably explains the b1.ThemeColor issue too. Any idea on cf1.Interior.InvertIfNegative?

    – James Carlyle-Clarke
    Nov 26 '18 at 9:24






  • 1





    Nah, the b1.ThemeColor issue is still an issue. Only occurs on some of the borders, not all of them. Seems to be where there is a line in the format. And I just found a note on that: Attempting to access a theme color for an object whose color is not currently themed will result in an invalid request run-time error Now I just need to figure out how to tell if a color is themed... :( Thanks for all your help, that was great

    – James Carlyle-Clarke
    Nov 26 '18 at 9:31
















1














Actually I can reproduce the issue you describe.



The issue seems to be in Set b1 = cf1.Borders.item(xlEdgeBottom) which is correct according to the documentation FormatCondition.Borders property.



But there seems to be a bug, because the value of xlEdgeBottom is 9 (according to xlBordersIndex enumeration) and if we have a look into the debug of cf1.Borders we see that there is only item 1 … 4 (see image) where 4 seems to be the bottom border.



enter image description here



If no one else has a very good idea here I would say this looks like a Excel bug.



To workaround this you can use eg Set b1 = cf1.Borders.item(4) for the bottom border.





So the solution is …



that Set b1 = cf1.Borders.item(xlBottom) actually worked for me.



Obviously the FormatCondition.Borders doesn't use the correct xlBordersIndex enumeration as it should do but instead uses xlTop, xlLeft, xlBottom, xlRight.



Also refer to FormatConditions border on a single edge.



But still this is not in accordance with the documentation and must be a bug.






share|improve this answer


























  • Honestly, I'd been wondering vaguely about that (as I checked the cf1.Borders.Count value somewhere else) but figured that Excel must just make it work somehow, perhaps by the valid items in the collection starting at an index of 5, or something - I'm not as familiar with the nitty gritty of VBA as I am of c#, and since I could see that at least some of the properties of the Border seemed valid, it never occurred to me that the overall Border might not be.

    – James Carlyle-Clarke
    Nov 26 '18 at 9:19













  • I should mention, if only for others who read this under different circumstances, that it might conceivably only be like this for Borders on Conditional Formatting... normal Borders on a Range might work perfectly normally

    – James Carlyle-Clarke
    Nov 26 '18 at 9:21











  • Obviously the FormatCondition.Borders does not use the right xlBordersIndex enumeration. Instead it uses xlTop, xlLeft, xlBottom, xlRight. But according to the documentation that's wrong and must be a bug.

    – Pᴇʜ
    Nov 26 '18 at 9:22













  • Agreed. This presumably explains the b1.ThemeColor issue too. Any idea on cf1.Interior.InvertIfNegative?

    – James Carlyle-Clarke
    Nov 26 '18 at 9:24






  • 1





    Nah, the b1.ThemeColor issue is still an issue. Only occurs on some of the borders, not all of them. Seems to be where there is a line in the format. And I just found a note on that: Attempting to access a theme color for an object whose color is not currently themed will result in an invalid request run-time error Now I just need to figure out how to tell if a color is themed... :( Thanks for all your help, that was great

    – James Carlyle-Clarke
    Nov 26 '18 at 9:31














1












1








1







Actually I can reproduce the issue you describe.



The issue seems to be in Set b1 = cf1.Borders.item(xlEdgeBottom) which is correct according to the documentation FormatCondition.Borders property.



But there seems to be a bug, because the value of xlEdgeBottom is 9 (according to xlBordersIndex enumeration) and if we have a look into the debug of cf1.Borders we see that there is only item 1 … 4 (see image) where 4 seems to be the bottom border.



enter image description here



If no one else has a very good idea here I would say this looks like a Excel bug.



To workaround this you can use eg Set b1 = cf1.Borders.item(4) for the bottom border.





So the solution is …



that Set b1 = cf1.Borders.item(xlBottom) actually worked for me.



Obviously the FormatCondition.Borders doesn't use the correct xlBordersIndex enumeration as it should do but instead uses xlTop, xlLeft, xlBottom, xlRight.



Also refer to FormatConditions border on a single edge.



But still this is not in accordance with the documentation and must be a bug.






share|improve this answer















Actually I can reproduce the issue you describe.



The issue seems to be in Set b1 = cf1.Borders.item(xlEdgeBottom) which is correct according to the documentation FormatCondition.Borders property.



But there seems to be a bug, because the value of xlEdgeBottom is 9 (according to xlBordersIndex enumeration) and if we have a look into the debug of cf1.Borders we see that there is only item 1 … 4 (see image) where 4 seems to be the bottom border.



enter image description here



If no one else has a very good idea here I would say this looks like a Excel bug.



To workaround this you can use eg Set b1 = cf1.Borders.item(4) for the bottom border.





So the solution is …



that Set b1 = cf1.Borders.item(xlBottom) actually worked for me.



Obviously the FormatCondition.Borders doesn't use the correct xlBordersIndex enumeration as it should do but instead uses xlTop, xlLeft, xlBottom, xlRight.



Also refer to FormatConditions border on a single edge.



But still this is not in accordance with the documentation and must be a bug.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 26 '18 at 9:26

























answered Nov 26 '18 at 9:12









PᴇʜPᴇʜ

23.7k62952




23.7k62952













  • Honestly, I'd been wondering vaguely about that (as I checked the cf1.Borders.Count value somewhere else) but figured that Excel must just make it work somehow, perhaps by the valid items in the collection starting at an index of 5, or something - I'm not as familiar with the nitty gritty of VBA as I am of c#, and since I could see that at least some of the properties of the Border seemed valid, it never occurred to me that the overall Border might not be.

    – James Carlyle-Clarke
    Nov 26 '18 at 9:19













  • I should mention, if only for others who read this under different circumstances, that it might conceivably only be like this for Borders on Conditional Formatting... normal Borders on a Range might work perfectly normally

    – James Carlyle-Clarke
    Nov 26 '18 at 9:21











  • Obviously the FormatCondition.Borders does not use the right xlBordersIndex enumeration. Instead it uses xlTop, xlLeft, xlBottom, xlRight. But according to the documentation that's wrong and must be a bug.

    – Pᴇʜ
    Nov 26 '18 at 9:22













  • Agreed. This presumably explains the b1.ThemeColor issue too. Any idea on cf1.Interior.InvertIfNegative?

    – James Carlyle-Clarke
    Nov 26 '18 at 9:24






  • 1





    Nah, the b1.ThemeColor issue is still an issue. Only occurs on some of the borders, not all of them. Seems to be where there is a line in the format. And I just found a note on that: Attempting to access a theme color for an object whose color is not currently themed will result in an invalid request run-time error Now I just need to figure out how to tell if a color is themed... :( Thanks for all your help, that was great

    – James Carlyle-Clarke
    Nov 26 '18 at 9:31



















  • Honestly, I'd been wondering vaguely about that (as I checked the cf1.Borders.Count value somewhere else) but figured that Excel must just make it work somehow, perhaps by the valid items in the collection starting at an index of 5, or something - I'm not as familiar with the nitty gritty of VBA as I am of c#, and since I could see that at least some of the properties of the Border seemed valid, it never occurred to me that the overall Border might not be.

    – James Carlyle-Clarke
    Nov 26 '18 at 9:19













  • I should mention, if only for others who read this under different circumstances, that it might conceivably only be like this for Borders on Conditional Formatting... normal Borders on a Range might work perfectly normally

    – James Carlyle-Clarke
    Nov 26 '18 at 9:21











  • Obviously the FormatCondition.Borders does not use the right xlBordersIndex enumeration. Instead it uses xlTop, xlLeft, xlBottom, xlRight. But according to the documentation that's wrong and must be a bug.

    – Pᴇʜ
    Nov 26 '18 at 9:22













  • Agreed. This presumably explains the b1.ThemeColor issue too. Any idea on cf1.Interior.InvertIfNegative?

    – James Carlyle-Clarke
    Nov 26 '18 at 9:24






  • 1





    Nah, the b1.ThemeColor issue is still an issue. Only occurs on some of the borders, not all of them. Seems to be where there is a line in the format. And I just found a note on that: Attempting to access a theme color for an object whose color is not currently themed will result in an invalid request run-time error Now I just need to figure out how to tell if a color is themed... :( Thanks for all your help, that was great

    – James Carlyle-Clarke
    Nov 26 '18 at 9:31

















Honestly, I'd been wondering vaguely about that (as I checked the cf1.Borders.Count value somewhere else) but figured that Excel must just make it work somehow, perhaps by the valid items in the collection starting at an index of 5, or something - I'm not as familiar with the nitty gritty of VBA as I am of c#, and since I could see that at least some of the properties of the Border seemed valid, it never occurred to me that the overall Border might not be.

– James Carlyle-Clarke
Nov 26 '18 at 9:19







Honestly, I'd been wondering vaguely about that (as I checked the cf1.Borders.Count value somewhere else) but figured that Excel must just make it work somehow, perhaps by the valid items in the collection starting at an index of 5, or something - I'm not as familiar with the nitty gritty of VBA as I am of c#, and since I could see that at least some of the properties of the Border seemed valid, it never occurred to me that the overall Border might not be.

– James Carlyle-Clarke
Nov 26 '18 at 9:19















I should mention, if only for others who read this under different circumstances, that it might conceivably only be like this for Borders on Conditional Formatting... normal Borders on a Range might work perfectly normally

– James Carlyle-Clarke
Nov 26 '18 at 9:21





I should mention, if only for others who read this under different circumstances, that it might conceivably only be like this for Borders on Conditional Formatting... normal Borders on a Range might work perfectly normally

– James Carlyle-Clarke
Nov 26 '18 at 9:21













Obviously the FormatCondition.Borders does not use the right xlBordersIndex enumeration. Instead it uses xlTop, xlLeft, xlBottom, xlRight. But according to the documentation that's wrong and must be a bug.

– Pᴇʜ
Nov 26 '18 at 9:22







Obviously the FormatCondition.Borders does not use the right xlBordersIndex enumeration. Instead it uses xlTop, xlLeft, xlBottom, xlRight. But according to the documentation that's wrong and must be a bug.

– Pᴇʜ
Nov 26 '18 at 9:22















Agreed. This presumably explains the b1.ThemeColor issue too. Any idea on cf1.Interior.InvertIfNegative?

– James Carlyle-Clarke
Nov 26 '18 at 9:24





Agreed. This presumably explains the b1.ThemeColor issue too. Any idea on cf1.Interior.InvertIfNegative?

– James Carlyle-Clarke
Nov 26 '18 at 9:24




1




1





Nah, the b1.ThemeColor issue is still an issue. Only occurs on some of the borders, not all of them. Seems to be where there is a line in the format. And I just found a note on that: Attempting to access a theme color for an object whose color is not currently themed will result in an invalid request run-time error Now I just need to figure out how to tell if a color is themed... :( Thanks for all your help, that was great

– James Carlyle-Clarke
Nov 26 '18 at 9:31





Nah, the b1.ThemeColor issue is still an issue. Only occurs on some of the borders, not all of them. Seems to be where there is a line in the format. And I just found a note on that: Attempting to access a theme color for an object whose color is not currently themed will result in an invalid request run-time error Now I just need to figure out how to tell if a color is themed... :( Thanks for all your help, that was great

– James Carlyle-Clarke
Nov 26 '18 at 9:31




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53474250%2fstrange-errors-reading-properties-of-a-formatcondition%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Feedback on college project

Futebolista

Albești (Vaslui)