View Single Post
  #7  
Old March 14th, 2005, 07:53 PM
Steve Rindsberg
external usenet poster
 
Posts: n/a
Default

In article , John wrote:
Ok, just discovered the answer.......it turns out there is also an "en dash"
(as well as an "em dash"), which is Chr(150) not 151.


To simplify things, and assuming you're using PPT2000 or higher, consider using
Replace a couple times before running the other code here.

Decide what character you want to use for the dash then use Replace to replace
other variants with your desired character:

Function NormalizeDashes(sTemp as String) as String

sTemp = Replace(sTemp, " -- ", " " & Chr(150) & " ")
sTemp = Replace(sTemp, " " & chr(151) & " ", " " & Chr(150) & " ")
' etc
NormalizeDashes = sTemp

End Function


Also discovered, for anyone whose interested, that to avoid picking up the
dash in a word in the headline part that I needed to add the spaces either
side of it. ie(" " & Chr(150) & " ")

Anyway, thanks very much for your help David.

Best regards

John

"John" wrote in message
...
Hi David,

Thanks very much for the help. It does the job perfectly. One issue I've
come up with is that in certain cases, there appears to be "long dashes"
as opposed to normal short dashes. I've added the two possibilities
(using txtHyphen), but it still doesn't appear to find the "em dash" (at
least I've discovered that much!).

(I also discovered that if there is another dash later in the paragraph
and a "long dash" in the correct place it skips the "long dash" and
formats the lot up to the secondary dash, so...I've included a test to
find the smaller number.)

Now I guess that the problem is either a) that the "long dash" is not an
em dash at all (in which case, what is it?) and so that's why it isn't
being picked up, or b) there's still something I'm not doing correctly.
Can you tell from the code which it is?

Thanks again

John

Sub FormatTextShapes()

Dim shp As Shape
Dim txtPara As TextRange
Dim txtDash As TextRange
Dim txtHyphen As TextRange
Dim endLarge As Long
Dim stSld As Integer 'start slide for procedure

stSld = InputBox("Enter start slide number:" & vbCr & _
"(ie don't include summary sheets).", "Start Slide", "4")

For x = stSld To ActivePresentation.Slides.Count
For Each shp In ActivePresentation.Slides(x).Shapes
Debug.Print x
If shp.HasTextFrame = msoTrue Then
If shp.Width 600 And shp.Height 375 And shp.Type = 1
Then
With shp
.Fill.Transparency = 0#
.Left = 15.75
.Top = 85.75
.Width = 660#
With .TextFrame.TextRange
With .ParagraphFormat
.Alignment = ppAlignJustify
.SpaceWithin = 1
.SpaceBefore = 0
.SpaceAfter = 0
End With
With .Font
.Name = "Arial"
.Size = 12
End With
End With
End With
For Each txtPara In shp.TextFrame.TextRange.Paragraphs
Set txtDash = txtPara.Find(Chr(45)) '"-")
Set txtHyphen = txtPara.Find(Chr(151)) '"-")
'If both dash and hyphen found check which is smaller
If Not txtDash Is Nothing And Not txtHyphen Is Nothing
Then
If txtDash txtHyphen Then
endLarge = txtDash.Start - txtPara.Start
Else
endLarge = txtHyphen.Start - txtPara.Start
End If
'If hyphen only found
ElseIf txtDash Is Nothing And Not txtHyphen Is Nothing
Then
endLarge = txtHyphen.Start - txtPara.Start
'If dash only found
ElseIf txtHyphen Is Nothing And Not txtDash Is Nothing
Then
endLarge = txtDash.Start - txtPara.Start
'If neither dash nor hyphen found
Else
endLarge = 0
End If
txtPara.Characters(1, endLarge).Font.Size = 18
Next txtPara
End If
End If
Next shp
Next x
End Sub


"David M. Marcovitz" wrote in message
48.16...
This code is set to do shape 2 on the current slide, but you can copy the
guts of it into your current loop as you go from shape to shape. In fact
the only thing you should have to change is the With line (since you are
already messing with the text in the shape, I assume you already checked
in your code to be sure the shape has a textframe; if not, add a check
for that):

Sub EnlargeHeading()
Dim myPar As TextRange
Dim dashRange As TextRange
Dim endLarge As Long
With ActivePresentation.SlideShowWindow.View.Slide.Shap es(2)
For Each myPar In .TextFrame.TextRange.Paragraphs
Set dashRange = myPar.Find("-")
If dashRange Is Nothing Then
endLarge = 0
Else
endLarge = dashRange.Start - myPar.Start
End If
MsgBox endLarge
myPar.Characters(1, endLarge).Font.Size = 16
Next myPar
End With
End Sub

--David

--
David M. Marcovitz
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.loyola.edu/education/PowerfulPowerPoint/

"John" wrote in
:

Headline Text Headline Text Headline Text Headline Text - body text
body text body text body text body text body text body text body text
body text body text body text body text body text body text body text
body text body text body text body text body text body text body text
body text body text body text body text body text body text body text
body text.

Headline Text Headline Text Headline Text Headline Text - body text
body text body text body text body text body text body text body text
body text body text body text body text body text body text body text
body text body text body text body text body text body text body text
body text body text body text body text body text body text body text
body text.

Headline Text Headline Text Headline Text Headline Text - body text
body text body text body text body text body text body text body text
body text body text body text body text body text body text body text
body text body text body text body text body text body text body text
body text body text body text body text body text body text body text
body text.

Headline Text Headline Text Headline Text Headline Text - body text
body text body text body text body text body text body text body text
body text body text body text body text body text body text body text
body text body text body text body text body text body text body text
body text body text body text body text body text body text body text
body text.






-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================