Partial Underline check for a shape in Powerpoint not working?











up vote
2
down vote

favorite
1












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 ???










share|improve this question






















  • Update 1: Microsoft took the ticket for development. github.com/MicrosoftDocs/VBA-Docs/issues/462
    – Chandraprakash
    Nov 20 at 8:28

















up vote
2
down vote

favorite
1












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 ???










share|improve this question






















  • Update 1: Microsoft took the ticket for development. github.com/MicrosoftDocs/VBA-Docs/issues/462
    – Chandraprakash
    Nov 20 at 8:28















up vote
2
down vote

favorite
1









up vote
2
down vote

favorite
1






1





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 ???










share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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




















  • 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














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.






share|improve this answer




























    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
    }





    share|improve this answer























      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',
      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%2f53368191%2fpartial-underline-check-for-a-shape-in-powerpoint-not-working%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      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.






      share|improve this answer

























        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.






        share|improve this answer























          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.






          share|improve this answer












          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.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 19 at 16:48









          Steve Rindsberg

          10k11526




          10k11526
























              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
              }





              share|improve this answer



























                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
                }





                share|improve this answer

























                  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
                  }





                  share|improve this answer














                  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
                  }






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Nov 20 at 9:10









                  Ashish Kamble

                  613419




                  613419










                  answered Nov 20 at 8:11









                  Chandraprakash

                  317




                  317






























                       

                      draft saved


                      draft discarded



















































                       


                      draft saved


                      draft discarded














                      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





















































                      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

                      Costa Masnaga

                      Fotorealismo

                      Sidney Franklin