HELP!! Two Questions to create a Macro

P

Prasant

Hi Experts,
Please see the below two questions.
Question I
I want to create a macro which finds the extra spaces and deletes. Situation
is, After completing the work in ppt, I have to search for the extra spaces
and remove, like double/triple space after periods to single space, removing
space before and after slash, making two hyphens to endash etc. I created a
macro in Word but couldn't make it in PPT. Instaed of searching and removing
each property one by one, I need a macro which searches all above properties
and removes the extra spaces. Can anyone please give me the code for what I
require? I think it is simple but I'm unable to figure it out.

Question II
I want to create a macro button which by clicking, pastes the text
automatically in "unformatted text". It helps and also saves a lot of time
otherwise, everytime I need to select paste special and select unformatted
text.

Is there a way to create a macro with that function? The copied text should
get pasted as unformatted text by clicking the button. I just need the macro.
I can do the button creation.


Thanks in Advance. Your help is really valuable and appreciated.

Awaiting...
Prasant
 
T

T Lavedas

Hi Experts,
Please see the below two questions.
Question I
I want to create a macro which finds the extra spaces and deletes. Situation
is, After completing the work in ppt, I have to search for the extra spaces
and remove, like double/triple space after periods to single space, removing
space before and after slash, making two hyphens to endash etc. I created a
macro in Word but couldn't make it in PPT. Instaed of searching and removing
each property one by one, I need a macro which searches all above properties
and removes the extra spaces. Can anyone please give me the code for what I
require? I think it is simple but I'm unable to figure it out.

Try ...

Sub ReplaceText()

Dim oSld As Slide
Dim oShp As Shape
Dim oTxtRng As TextRange
Dim oTmpRng As TextRange
Dim aReplacements, aTemp
Dim sReplacement As Variant
sReplacements = ". |. || /|/||/ |/||--|" & ChrW(&H2013)
aReplacements = Split(sReplacements, "||")
For Each oSld In Application.ActivePresentation.Slides
For Each oShp In oSld.Shapes
If oShp.HasTextFrame Then
Set oTxtRng = oShp.TextFrame.TextRange
If oTxtRng.Length > 0 Then
For Each sReplacement In aReplacements
aTemp = Split(sReplacement, "|")
Set oTmpRng =
oTxtRng.Replace(FindWhat:=aTemp(0), _
Replacewhat:=aTemp(1), WholeWords:=False)
Do While Not oTmpRng Is Nothing
Set oTxtRng =
oTxtRng.Characters(oTmpRng.Start + _
oTmpRng.Length, oTxtRng.Length)
Set oTmpRng =
oTxtRng.Replace(FindWhat:=aTemp(0), _
Replacewhat:=aTemp(1),
WholeWords:=False)
Loop
Next sReplacement
End If
End If
Next oShp
Next oSld
MsgBox "Done"

End Sub
Question II
I want to create a macro button which by clicking, pastes the text
automatically in "unformatted text". It helps and also saves a lot of time
otherwise, everytime I need to select paste special and select unformatted
text.

Sub PasteText()

ActiveWindow.View.PasteSpecial DataType:=ppPasteText
End Sub
Is there a way to create a macro with that function? The copied text should
get pasted as unformatted text by clicking the button. I just need the macro.
I can do the button creation.

Thanks in Advance. Your help is really valuable and appreciated.

Awaiting...
Prasant

HTH

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top