The Amsterdam Excel Summit

Results 1 to 5 of 5

Thread: Powerpoint underline style

  1. #1

    Powerpoint underline style

    I can't figure out the syntax for the new underline styles in Powerpoint 2007 onwards. I need to set a dotted underline to a TextRange (underline style > dotted line from the Font dialog) but can't find the attribute. I can only work out how to turn on underline and it uses the default solid underline.

    Code currently like this..

    With rngUnderline
    .Font.Underline = msoTrue
    End With

    You'd think there was a .Font.Underline.Style property but seemingly not. Anyone got any ideas?
    Last edited by lesaussice; 04-16-2012 at 04:42 AM.

  2. #2
    To use the new text features you must work with the TextFrame2 object. In 2007 this is a bit broken so you might want to explain how you referenced mgunderline. In 2010 you can use TextRange2.

    [VBA]Sub newstuff()
    'This is broken in 2007 but works in 2010!
    Dim otx2 As TextRange2
    Set otx2 = ActiveWindow.Selection.TextRange2
    otx2.Font.UnderlineStyle = msoUnderlineDotDashLine
    End Sub[/VBA]
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials

  3. #3

    Great, that's solved it..

    RngUnderline was set to a specific character range via the TextFrame rather than the TextFrame2 object. Like you say, things are a bit broken in PPT 2007 but I'm now able to use UnderlineStyle to apply my dotted underline.


  4. #4
    Can you try changing the undeline color with vba and tell me what you see.
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials

  5. #5
    Sorry.. Taken me a while to come back to this. I did get around the problem, but I had to do it by referring to the shape's textframe2 (and then the characters within it) rather than setting those characters as a range and then applying the underlinestyle to it. The latter (bizarely) results in PPT not exposing the relevant properties.

    Coming from Excel / Access, PPT VBA is quite odd and seems a bit unloved by MS..

Posting Permissions

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