locked
Powerpoint 2010 Clear all formatting RRS feed

  • Question

  • I'm trying to find the VBA-code for the "Clear all formatting" button in Powerpoint 2010. Another thread suggests that "Selection.ClearFormatting" is the solution but I can't get that to work no matter what I do. It's not described in the Object Model reference.

    Regards

    Roger

    Tuesday, May 27, 2014 6:48 AM

All replies

  • I do not know what you mean writing "Clear all formatting"

    That is a code to change font in all slides.

    Sub zmiana_czcionki_w_PPS()
    'MVP OShon from VBATools.pl
    Dim shp As Shape, sl&
    For sl = 1 To ActivePresentation.Slides.Count
     For Each shp In ActivePresentation.Slides(sl).Shapes
       On Error Resume Next
       shp.TextFrame.TextRange.Font.name = "Arial"
     Next
    Next sl
    End Sub

    Modyf that code to your purposes.


    Oskar Shon, Office System MVP - www.VBATools.pl
    if Helpful; Answer when a problem solved

    Thursday, June 5, 2014 7:52 PM
    Answerer
  • Thanks for your answer.

    In Powerpoint 2010 there is a button in the Home tab called "Clear all formatting" which clears all formatting (such as bold, underline, italics, color and more) from my text and return text to its default formatting styles. Is there a way to access that button from VBA?

    My solution right now is to change font, color etc. in all slides to match the default formatting styles but I'm kind of lazy so if it's possible to access the code behind the button it would be nice. :)

    Have a good day,

    Roger

    Friday, June 13, 2014 1:54 PM
  • Sorry cant find that opction in VBA

       With shp.TextFrame.TextRange.Font
        .Bold = msoFalse
        .Italic = msoFalse
        .Name = "Calibri"
        .Size = 24
       'etc..
       End With

    Also you can use Excel's schortcut command

    Sub shortcut()
    'MVP OShon from VBATools.pl
        Dim xl As Object
        Set xl = CreateObject("Excel.Application")
        xl.Application.SendKeys "%G"
        xl.Application.SendKeys "ER"
        Set xl = Nothing
    End Sub

    Fire this code from PP using [Alt+F8]


    Oskar Shon, Office System MVP - www.VBATools.pl
    if Helpful; Answer when a problem solved

    Friday, June 13, 2014 2:23 PM
    Answerer
  • There is no built in support for Clear Formatting in excel.

    What I did was store the text in a variable, delete the text that's currently in the text range, and then set my text to what is saved in my variable.

    This seems to apply the default formatting that your layout would have assigned to that text box.

    • Proposed as answer by Eltee27 Friday, March 15, 2019 2:02 AM
    Friday, March 15, 2019 2:02 AM