Errors

D

Designingsally

I m not familar with vba ppt. The logically the macros are fine but i m
gettitn some issues as my syntax is wrong i ll be glad if someone helps me
out.
I have placed 3 macros below. I ll be happy if someone turns out to help
me. thanks
Sub comments()

Dim vFindText As Variant
Dim i As Long
vFindText = Array("Because", "Also", "Since")
For i = 0 To UBound(vFindText)
With Selection
.HomeKey wdStory ' getting run time error 424 here.
With .FInd
.ClearFormatting
.Format = False
..MatchCase = True
..MatchWholeWord = True
..MatchWildcards = False
..MatchSoundsLike = False
..MatchAllWordForms = False
Do While .Execute(findText:=vFindText(i), _
Forward:=True)
Selection.comments.Add _
Range:=Selection.Range, Text:="Please don't begin
sentences with these words."
Loop
End With
End With
Next

End Sub


Sub FindAndReplace()


'
' FindAndReplace Macro

Dim oRng As TextRange
Dim sRep As String
Dim sFindText As String
Dim sRepText As String
sFindText = "etc" 'Replace to find
sRepText = "and so on" 'Replace to replace
With Selection
..HomeKey wdStory' run time error 424 and ppt cant run in the break mode.
With .Find
..ClearFormatting
..Replacement.ClearFormatting
..Wrap = wdFindContinue
..Format = False
..MatchCase = False
..MatchWholeWord = True
..MatchWildcards = False
..MatchSoundsLike = False
..MatchAllWordForms = False
While .Execute(findText:=sFindText)
Set oRng = Selection.Range
sRep = MsgBox("Replace the highlighted word" & " on page " &
Selection.Information(wdActiveEndPageNumber) & " with " & Chr(34) & "and so
on" & Chr(34) & ". ", vbYesNoCancel, "Recommended Word")
If sRep = vbCancel Then
Exit Sub
End If
If sRep = vbYes Then
oRng.Text = sRepText
End If
Wend
End With
End With
End Sub

Sub NoteColon()
Dim oRng As TextRange
Set oRng = ActiveDocument.Range
With oRng
With .Find ' complie error arugement not found
.ClearFormatting
.Replacement.ClearFormatting
Do While .Execute("NOTE: [A-Za-z]{1,}>", MatchWildcards:=True)
oRng.Select 'Word processing
Select Case MsgBox(Chr(34) & "Note" & Chr(34) & " on page " &
Selection.Information(wdActiveEndPageNumber) & " should not be followed by "
& Chr(34) & "colon." & Chr(34), vbYesNoCancel, "Colon")
Case vbCancel
Exit Sub
Case vbYes
oRng = Replace(oRng.Text, ":", "")
If oRng.Words.Last.Characters.First.Case <> wdUpperCase Then
oRng.Words.Last.Characters.First.Case = wdUpperCase
End If
End Select
oRng.Collapse wdCollapseEnd
Loop
End With
End With
End Sub
 
J

John Wilson

See your other post. Again these are Word specific. There are examples of
replace macros in PowerPoint here
http://skp.mvps.org/ppt00025.htm#2
http://www.pptalchemy.co.uk/vbasamples.html
Which might give you some pointers
--
john ATSIGN PPTAlchemy.co.uk

Free PPT Hints, Tips and Tutorials
http://www.pptalchemy.co.uk/powerpoint_hints_and_tips_tutorials.html
PPTLive Atlanta Oct 11-14 2009




Designingsally said:
I m not familar with vba ppt. The logically the macros are fine but i m
gettitn some issues as my syntax is wrong i ll be glad if someone helps me
out.
I have placed 3 macros below. I ll be happy if someone turns out to help
me. thanks
Sub comments()

Dim vFindText As Variant
Dim i As Long
vFindText = Array("Because", "Also", "Since")
For i = 0 To UBound(vFindText)
With Selection
.HomeKey wdStory ' getting run time error 424 here.
With .FInd
.ClearFormatting
.Format = False
.MatchCase = True
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
Do While .Execute(findText:=vFindText(i), _
Forward:=True)
Selection.comments.Add _
Range:=Selection.Range, Text:="Please don't begin
sentences with these words."
Loop
End With
End With
Next

End Sub


Sub FindAndReplace()


'
' FindAndReplace Macro

Dim oRng As TextRange
Dim sRep As String
Dim sFindText As String
Dim sRepText As String
sFindText = "etc" 'Replace to find
sRepText = "and so on" 'Replace to replace
With Selection
.HomeKey wdStory' run time error 424 and ppt cant run in the break mode.
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
While .Execute(findText:=sFindText)
Set oRng = Selection.Range
sRep = MsgBox("Replace the highlighted word" & " on page " &
Selection.Information(wdActiveEndPageNumber) & " with " & Chr(34) & "and so
on" & Chr(34) & ". ", vbYesNoCancel, "Recommended Word")
If sRep = vbCancel Then
Exit Sub
End If
If sRep = vbYes Then
oRng.Text = sRepText
End If
Wend
End With
End With
End Sub

Sub NoteColon()
Dim oRng As TextRange
Set oRng = ActiveDocument.Range
With oRng
With .Find ' complie error arugement not found
.ClearFormatting
.Replacement.ClearFormatting
Do While .Execute("NOTE: [A-Za-z]{1,}>", MatchWildcards:=True)
oRng.Select 'Word processing
Select Case MsgBox(Chr(34) & "Note" & Chr(34) & " on page " &
Selection.Information(wdActiveEndPageNumber) & " should not be followed by "
& Chr(34) & "colon." & Chr(34), vbYesNoCancel, "Colon")
Case vbCancel
Exit Sub
Case vbYes
oRng = Replace(oRng.Text, ":", "")
If oRng.Words.Last.Characters.First.Case <> wdUpperCase Then
oRng.Words.Last.Characters.First.Case = wdUpperCase
End If
End Select
oRng.Collapse wdCollapseEnd
Loop
End With
End With
End Sub
 
D

Designingsally

in the macro code i have displayed some error message is that not possible to
change that?

--
I believe in Hope.

DesigningSally


John Wilson said:
See your other post. Again these are Word specific. There are examples of
replace macros in PowerPoint here
http://skp.mvps.org/ppt00025.htm#2
http://www.pptalchemy.co.uk/vbasamples.html
Which might give you some pointers
--
john ATSIGN PPTAlchemy.co.uk

Free PPT Hints, Tips and Tutorials
http://www.pptalchemy.co.uk/powerpoint_hints_and_tips_tutorials.html
PPTLive Atlanta Oct 11-14 2009




Designingsally said:
I m not familar with vba ppt. The logically the macros are fine but i m
gettitn some issues as my syntax is wrong i ll be glad if someone helps me
out.
I have placed 3 macros below. I ll be happy if someone turns out to help
me. thanks
Sub comments()

Dim vFindText As Variant
Dim i As Long
vFindText = Array("Because", "Also", "Since")
For i = 0 To UBound(vFindText)
With Selection
.HomeKey wdStory ' getting run time error 424 here.
With .FInd
.ClearFormatting
.Format = False
.MatchCase = True
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
Do While .Execute(findText:=vFindText(i), _
Forward:=True)
Selection.comments.Add _
Range:=Selection.Range, Text:="Please don't begin
sentences with these words."
Loop
End With
End With
Next

End Sub


Sub FindAndReplace()


'
' FindAndReplace Macro

Dim oRng As TextRange
Dim sRep As String
Dim sFindText As String
Dim sRepText As String
sFindText = "etc" 'Replace to find
sRepText = "and so on" 'Replace to replace
With Selection
.HomeKey wdStory' run time error 424 and ppt cant run in the break mode.
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
While .Execute(findText:=sFindText)
Set oRng = Selection.Range
sRep = MsgBox("Replace the highlighted word" & " on page " &
Selection.Information(wdActiveEndPageNumber) & " with " & Chr(34) & "and so
on" & Chr(34) & ". ", vbYesNoCancel, "Recommended Word")
If sRep = vbCancel Then
Exit Sub
End If
If sRep = vbYes Then
oRng.Text = sRepText
End If
Wend
End With
End With
End Sub

Sub NoteColon()
Dim oRng As TextRange
Set oRng = ActiveDocument.Range
With oRng
With .Find ' complie error arugement not found
.ClearFormatting
.Replacement.ClearFormatting
Do While .Execute("NOTE: [A-Za-z]{1,}>", MatchWildcards:=True)
oRng.Select 'Word processing
Select Case MsgBox(Chr(34) & "Note" & Chr(34) & " on page " &
Selection.Information(wdActiveEndPageNumber) & " should not be followed by "
& Chr(34) & "colon." & Chr(34), vbYesNoCancel, "Colon")
Case vbCancel
Exit Sub
Case vbYes
oRng = Replace(oRng.Text, ":", "")
If oRng.Words.Last.Characters.First.Case <> wdUpperCase Then
oRng.Words.Last.Characters.First.Case = wdUpperCase
End If
End Select
oRng.Collapse wdCollapseEnd
Loop
End With
End With
End Sub
 
B

Bill Dilworth

Hi Sally,

PowerPoint and Word are different programs (just like Excel and Word are).
The constants and instructions are different between them. As I see it, you
can convert the PowerPoint text to a Word project (difficult and imperfect,
at best) and run your code, or re-code your project based on the PowerPoint
Object Model. Until then, you are banging away at a round hole with a
square peg.

There is no wdWord in PowerPoint, it is a Word constant.
There is no .MatchWholeWord command in PowerPoint, again it is a Word
command.

Look at http://msdn.microsoft.com/en-us/library/aa213568(office.11).aspx


Bill Dilworth


Designingsally said:
in the macro code i have displayed some error message is that not possible
to
change that?

--
I believe in Hope.

DesigningSally


John Wilson said:
See your other post. Again these are Word specific. There are examples of
replace macros in PowerPoint here
http://skp.mvps.org/ppt00025.htm#2
http://www.pptalchemy.co.uk/vbasamples.html
Which might give you some pointers
--
john ATSIGN PPTAlchemy.co.uk

Free PPT Hints, Tips and Tutorials
http://www.pptalchemy.co.uk/powerpoint_hints_and_tips_tutorials.html
PPTLive Atlanta Oct 11-14 2009




Designingsally said:
I m not familar with vba ppt. The logically the macros are fine but i m
gettitn some issues as my syntax is wrong i ll be glad if someone helps
me
out.
I have placed 3 macros below. I ll be happy if someone turns out to
help
me. thanks
Sub comments()

Dim vFindText As Variant
Dim i As Long
vFindText = Array("Because", "Also", "Since")
For i = 0 To UBound(vFindText)
With Selection
.HomeKey wdStory ' getting run time error 424 here.
With .FInd
.ClearFormatting
.Format = False
.MatchCase = True
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
Do While .Execute(findText:=vFindText(i), _
Forward:=True)
Selection.comments.Add _
Range:=Selection.Range, Text:="Please don't begin
sentences with these words."
Loop
End With
End With
Next

End Sub


Sub FindAndReplace()


'
' FindAndReplace Macro

Dim oRng As TextRange
Dim sRep As String
Dim sFindText As String
Dim sRepText As String
sFindText = "etc" 'Replace to find
sRepText = "and so on" 'Replace to replace
With Selection
.HomeKey wdStory' run time error 424 and ppt cant run in the break
mode.
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
While .Execute(findText:=sFindText)
Set oRng = Selection.Range
sRep = MsgBox("Replace the highlighted word" & " on page " &
Selection.Information(wdActiveEndPageNumber) & " with " & Chr(34) &
"and so
on" & Chr(34) & ". ", vbYesNoCancel, "Recommended Word")
If sRep = vbCancel Then
Exit Sub
End If
If sRep = vbYes Then
oRng.Text = sRepText
End If
Wend
End With
End With
End Sub

Sub NoteColon()
Dim oRng As TextRange
Set oRng = ActiveDocument.Range
With oRng
With .Find ' complie error arugement not found
.ClearFormatting
.Replacement.ClearFormatting
Do While .Execute("NOTE: [A-Za-z]{1,}>", MatchWildcards:=True)
oRng.Select 'Word processing
Select Case MsgBox(Chr(34) & "Note" & Chr(34) & " on page " &
Selection.Information(wdActiveEndPageNumber) & " should not be followed
by "
& Chr(34) & "colon." & Chr(34), vbYesNoCancel, "Colon")
Case vbCancel
Exit Sub
Case vbYes
oRng = Replace(oRng.Text, ":", "")
If oRng.Words.Last.Characters.First.Case <> wdUpperCase
Then
oRng.Words.Last.Characters.First.Case = wdUpperCase
End If
End Select
oRng.Collapse wdCollapseEnd
Loop
End With
End With
End Sub
 

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