Consulting

Results 1 to 8 of 8

Thread: Strikethrough in PowerPoint vba

  1. #1

    Strikethrough in PowerPoint vba

    Hi,

    I'm new to this community so I hope I have adhered to all of the rules with this post.

    I am trying to create a very crude 'tracked changes' add-in for PowerPoint. The macro would have a keyboard shortcut and button assigned to each of the following functions:

    1.) Format selected text as red and strikethrough
    2.) Format selected text as black and remove strikethrough
    3.) Search document for all text which is red with strikethrough as well as all text which is red only and delete/format as black respectively allowing the user to ignore instances on a case by case basis.

    The only problem is that the Font.StrikeThrough property of a TextRange does not appear to be accessible in PowerPoint vba. I have submitted feedback to Microsoft on this but I am hoping someone might be able to suggest a clever way (perhaps utilising excel's Font.StrikeThrough property) to achieve the above attempting to minimise any performance hit of opening another application.

    Thanks in advance!

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,702
    Location
    Try this -- uses .TextRange2, not .TextRange


    Sub ST()
        With ActiveWindow.Selection
            .TextRange2.Font.Strikethrough = msoTrue
            .TextRange2.Font.Fill.ForeColor.RGB = vbRed
        End With
    End Sub
    For ref: http://vba.relief.jp/powerpoint-vba-...-methods-list/
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  3. #3
    Exactly what I was looking for. Many thanks, Paul!

  4. #4
    Paul - I wonder if you might be able to help me further with the below please?

    I'm trying to use the below to search for all instances of strikethrough formatted text in a presentation:

    For each sld in Application.ActivePresentation.Slides
    For each shp in sld.Shapes
    If shp.HasTextFrame then
    Set txtrng = shp.TextFrame.TextRange2
    But apparently TextFrame doesn't support TextRange2 and TextRange doesn't have the strikethrough property that I need.

    Any ideas?

    Thanks again.
    Last edited by crossharu; 10-22-2017 at 08:11 AM. Reason: Code tags

  5. #5
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,702
    Location
    Sorry - that's too advanced for me -- I only know the very basics of PP VBA
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  6. #6
    No worries Paul. Has anyone else come across this problem?

    Thanks.

  7. #7
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    You need to use shp.TextFrame2.Textrange
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  8. #8
    Perfect, thanks John.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •