Partial Underline check for a shape in Powerpoint not working?
up vote
2
down vote
favorite
ppShape.TextFrame.TextRange.Font.Underline == MsoTriState.msoTrue
ppShape.TextFrame.TextRange.Font.Underline == MsoTriState.msoFalse
ppShape.TextFrame.TextRange.Font.Underline == MsoTriState.msoTriStateMixed
The above code checks whether a powerpoint shape has...
1. all the text underlined
2. all the text not underlined
3. partial text are underlined
The 3rd point, partial text are underlined are not working and returns false or true randomly for mixed underlinetext in shape.
This works perfectly fine for Bold and Italic, i.e
ppShape.TextFrame.TextRange.Font.Bold == MsoTriState.msoTriStateMixed
ppShape.TextFrame.TextRange.Font.Italic == MsoTriState.msoTriStateMixed
I also raised issue with Microsoft about this issue here in GitHub,
https://github.com/MicrosoftDocs/VBA-Docs/issues/462
Let me know if there are any way to fix this issue or at least there is any alternative work around for this problem ???
c# powerpoint partial shapes underline
add a comment |
up vote
2
down vote
favorite
ppShape.TextFrame.TextRange.Font.Underline == MsoTriState.msoTrue
ppShape.TextFrame.TextRange.Font.Underline == MsoTriState.msoFalse
ppShape.TextFrame.TextRange.Font.Underline == MsoTriState.msoTriStateMixed
The above code checks whether a powerpoint shape has...
1. all the text underlined
2. all the text not underlined
3. partial text are underlined
The 3rd point, partial text are underlined are not working and returns false or true randomly for mixed underlinetext in shape.
This works perfectly fine for Bold and Italic, i.e
ppShape.TextFrame.TextRange.Font.Bold == MsoTriState.msoTriStateMixed
ppShape.TextFrame.TextRange.Font.Italic == MsoTriState.msoTriStateMixed
I also raised issue with Microsoft about this issue here in GitHub,
https://github.com/MicrosoftDocs/VBA-Docs/issues/462
Let me know if there are any way to fix this issue or at least there is any alternative work around for this problem ???
c# powerpoint partial shapes underline
Update 1: Microsoft took the ticket for development. github.com/MicrosoftDocs/VBA-Docs/issues/462
– Chandraprakash
Nov 20 at 8:28
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
ppShape.TextFrame.TextRange.Font.Underline == MsoTriState.msoTrue
ppShape.TextFrame.TextRange.Font.Underline == MsoTriState.msoFalse
ppShape.TextFrame.TextRange.Font.Underline == MsoTriState.msoTriStateMixed
The above code checks whether a powerpoint shape has...
1. all the text underlined
2. all the text not underlined
3. partial text are underlined
The 3rd point, partial text are underlined are not working and returns false or true randomly for mixed underlinetext in shape.
This works perfectly fine for Bold and Italic, i.e
ppShape.TextFrame.TextRange.Font.Bold == MsoTriState.msoTriStateMixed
ppShape.TextFrame.TextRange.Font.Italic == MsoTriState.msoTriStateMixed
I also raised issue with Microsoft about this issue here in GitHub,
https://github.com/MicrosoftDocs/VBA-Docs/issues/462
Let me know if there are any way to fix this issue or at least there is any alternative work around for this problem ???
c# powerpoint partial shapes underline
ppShape.TextFrame.TextRange.Font.Underline == MsoTriState.msoTrue
ppShape.TextFrame.TextRange.Font.Underline == MsoTriState.msoFalse
ppShape.TextFrame.TextRange.Font.Underline == MsoTriState.msoTriStateMixed
The above code checks whether a powerpoint shape has...
1. all the text underlined
2. all the text not underlined
3. partial text are underlined
The 3rd point, partial text are underlined are not working and returns false or true randomly for mixed underlinetext in shape.
This works perfectly fine for Bold and Italic, i.e
ppShape.TextFrame.TextRange.Font.Bold == MsoTriState.msoTriStateMixed
ppShape.TextFrame.TextRange.Font.Italic == MsoTriState.msoTriStateMixed
I also raised issue with Microsoft about this issue here in GitHub,
https://github.com/MicrosoftDocs/VBA-Docs/issues/462
Let me know if there are any way to fix this issue or at least there is any alternative work around for this problem ???
c# powerpoint partial shapes underline
c# powerpoint partial shapes underline
asked Nov 19 at 4:10
Chandraprakash
317
317
Update 1: Microsoft took the ticket for development. github.com/MicrosoftDocs/VBA-Docs/issues/462
– Chandraprakash
Nov 20 at 8:28
add a comment |
Update 1: Microsoft took the ticket for development. github.com/MicrosoftDocs/VBA-Docs/issues/462
– Chandraprakash
Nov 20 at 8:28
Update 1: Microsoft took the ticket for development. github.com/MicrosoftDocs/VBA-Docs/issues/462
– Chandraprakash
Nov 20 at 8:28
Update 1: Microsoft took the ticket for development. github.com/MicrosoftDocs/VBA-Docs/issues/462
– Chandraprakash
Nov 20 at 8:28
add a comment |
2 Answers
2
active
oldest
votes
up vote
1
down vote
As a workaround, you can check each Run in the TextRange. In VBA, you could pass the shape to a function like this:
Function IsUnderlined(oSh As Shape) As Boolean
Dim oRng As TextRange
For Each oRng In oSh.TextFrame.TextRange.Runs
If oRng.Font.Underline Then
IsUnderlined = True
Exit Function
End If
Next
End Function
If any character in the text is underlined, the function will return True.
add a comment |
up vote
0
down vote
accepted
Thanks for shedding light on TextRange.Runs methods, which really is wonderful function which also saves a lot of performance rather than looping character.
I created a similar function in C#.Net to use it readily similar to default function.
using pp = Microsoft.Office.Interop.PowerPoint;
using Microsoft.Office.Core;
public static MsoTriState IsUnderlined(pp.Shape parShape)
{
int cntUnderline = 0;
foreach (pp.TextRange textTR in parShape.TextFrame.TextRange.Runs())
{
if (textTR.Font.Underline == MsoTriState.msoTrue)
{
cntUnderline++;
}
}
if (cntUnderline == 0)
{
//No Underline
return MsoTriState.msoFalse;
}
else if (parShape.TextFrame.TextRange.Runs().Count == cntUnderline)
{
//All Underline
return MsoTriState.msoTrue;
}
else if (parShape.TextFrame.TextRange.Runs().Count != cntUnderline)
{
//Mixed Underline
return MsoTriState.msoTriStateMixed;
}
return MsoTriState.msoTriStateToggle; //Consider as error
}
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
As a workaround, you can check each Run in the TextRange. In VBA, you could pass the shape to a function like this:
Function IsUnderlined(oSh As Shape) As Boolean
Dim oRng As TextRange
For Each oRng In oSh.TextFrame.TextRange.Runs
If oRng.Font.Underline Then
IsUnderlined = True
Exit Function
End If
Next
End Function
If any character in the text is underlined, the function will return True.
add a comment |
up vote
1
down vote
As a workaround, you can check each Run in the TextRange. In VBA, you could pass the shape to a function like this:
Function IsUnderlined(oSh As Shape) As Boolean
Dim oRng As TextRange
For Each oRng In oSh.TextFrame.TextRange.Runs
If oRng.Font.Underline Then
IsUnderlined = True
Exit Function
End If
Next
End Function
If any character in the text is underlined, the function will return True.
add a comment |
up vote
1
down vote
up vote
1
down vote
As a workaround, you can check each Run in the TextRange. In VBA, you could pass the shape to a function like this:
Function IsUnderlined(oSh As Shape) As Boolean
Dim oRng As TextRange
For Each oRng In oSh.TextFrame.TextRange.Runs
If oRng.Font.Underline Then
IsUnderlined = True
Exit Function
End If
Next
End Function
If any character in the text is underlined, the function will return True.
As a workaround, you can check each Run in the TextRange. In VBA, you could pass the shape to a function like this:
Function IsUnderlined(oSh As Shape) As Boolean
Dim oRng As TextRange
For Each oRng In oSh.TextFrame.TextRange.Runs
If oRng.Font.Underline Then
IsUnderlined = True
Exit Function
End If
Next
End Function
If any character in the text is underlined, the function will return True.
answered Nov 19 at 16:48
Steve Rindsberg
10k11526
10k11526
add a comment |
add a comment |
up vote
0
down vote
accepted
Thanks for shedding light on TextRange.Runs methods, which really is wonderful function which also saves a lot of performance rather than looping character.
I created a similar function in C#.Net to use it readily similar to default function.
using pp = Microsoft.Office.Interop.PowerPoint;
using Microsoft.Office.Core;
public static MsoTriState IsUnderlined(pp.Shape parShape)
{
int cntUnderline = 0;
foreach (pp.TextRange textTR in parShape.TextFrame.TextRange.Runs())
{
if (textTR.Font.Underline == MsoTriState.msoTrue)
{
cntUnderline++;
}
}
if (cntUnderline == 0)
{
//No Underline
return MsoTriState.msoFalse;
}
else if (parShape.TextFrame.TextRange.Runs().Count == cntUnderline)
{
//All Underline
return MsoTriState.msoTrue;
}
else if (parShape.TextFrame.TextRange.Runs().Count != cntUnderline)
{
//Mixed Underline
return MsoTriState.msoTriStateMixed;
}
return MsoTriState.msoTriStateToggle; //Consider as error
}
add a comment |
up vote
0
down vote
accepted
Thanks for shedding light on TextRange.Runs methods, which really is wonderful function which also saves a lot of performance rather than looping character.
I created a similar function in C#.Net to use it readily similar to default function.
using pp = Microsoft.Office.Interop.PowerPoint;
using Microsoft.Office.Core;
public static MsoTriState IsUnderlined(pp.Shape parShape)
{
int cntUnderline = 0;
foreach (pp.TextRange textTR in parShape.TextFrame.TextRange.Runs())
{
if (textTR.Font.Underline == MsoTriState.msoTrue)
{
cntUnderline++;
}
}
if (cntUnderline == 0)
{
//No Underline
return MsoTriState.msoFalse;
}
else if (parShape.TextFrame.TextRange.Runs().Count == cntUnderline)
{
//All Underline
return MsoTriState.msoTrue;
}
else if (parShape.TextFrame.TextRange.Runs().Count != cntUnderline)
{
//Mixed Underline
return MsoTriState.msoTriStateMixed;
}
return MsoTriState.msoTriStateToggle; //Consider as error
}
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
Thanks for shedding light on TextRange.Runs methods, which really is wonderful function which also saves a lot of performance rather than looping character.
I created a similar function in C#.Net to use it readily similar to default function.
using pp = Microsoft.Office.Interop.PowerPoint;
using Microsoft.Office.Core;
public static MsoTriState IsUnderlined(pp.Shape parShape)
{
int cntUnderline = 0;
foreach (pp.TextRange textTR in parShape.TextFrame.TextRange.Runs())
{
if (textTR.Font.Underline == MsoTriState.msoTrue)
{
cntUnderline++;
}
}
if (cntUnderline == 0)
{
//No Underline
return MsoTriState.msoFalse;
}
else if (parShape.TextFrame.TextRange.Runs().Count == cntUnderline)
{
//All Underline
return MsoTriState.msoTrue;
}
else if (parShape.TextFrame.TextRange.Runs().Count != cntUnderline)
{
//Mixed Underline
return MsoTriState.msoTriStateMixed;
}
return MsoTriState.msoTriStateToggle; //Consider as error
}
Thanks for shedding light on TextRange.Runs methods, which really is wonderful function which also saves a lot of performance rather than looping character.
I created a similar function in C#.Net to use it readily similar to default function.
using pp = Microsoft.Office.Interop.PowerPoint;
using Microsoft.Office.Core;
public static MsoTriState IsUnderlined(pp.Shape parShape)
{
int cntUnderline = 0;
foreach (pp.TextRange textTR in parShape.TextFrame.TextRange.Runs())
{
if (textTR.Font.Underline == MsoTriState.msoTrue)
{
cntUnderline++;
}
}
if (cntUnderline == 0)
{
//No Underline
return MsoTriState.msoFalse;
}
else if (parShape.TextFrame.TextRange.Runs().Count == cntUnderline)
{
//All Underline
return MsoTriState.msoTrue;
}
else if (parShape.TextFrame.TextRange.Runs().Count != cntUnderline)
{
//Mixed Underline
return MsoTriState.msoTriStateMixed;
}
return MsoTriState.msoTriStateToggle; //Consider as error
}
edited Nov 20 at 9:10
Ashish Kamble
613419
613419
answered Nov 20 at 8:11
Chandraprakash
317
317
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53368191%2fpartial-underline-check-for-a-shape-in-powerpoint-not-working%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
Update 1: Microsoft took the ticket for development. github.com/MicrosoftDocs/VBA-Docs/issues/462
– Chandraprakash
Nov 20 at 8:28