My macros are not running in ppt

D

Designingsally

I got this macro which i m tryin to run with power point. I m getting some
getting Compile Erro- User defined type not defined. But the macros work so
perfectly with Word. Whats the porblem can u help me out? Can someone help me
out.?

The code is displayed below. (I m sorry its a bit big- Thanks for the help)

Sub Led()
Dim oRng As Range
Dim oRngDup As Range
Dim rslt As VbMsgBoxResult
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = "<([A-Z]{2,})"
.MatchWildcards = True
.Wrap = wdFindStop
.Forward = True
While .Execute
oRng.Select
Select Case oRng.Text
'Exclude first case words.
Case Is = "TABLE", "OF", "RIO", "OST", "RLO", "NEXT", "CONTENTS",
"AUDIO", "TEXT", "NOTE", "TIP", "MCQ", "WILL", "TRADE", "OR"
oRng.Collapse wdCollapseEnd
'Process all other words
Case Else
Set oRngDup = oRng.Duplicate
With oRngDup
.Move wdCharacter, -5
.MoveEnd wdCharacter, 4
If Not .Text = "the " And Not .Text = "The " Then
If Not .Text = "THE " Then
Select Case MsgBox("Add " & Chr(34) & "the" & Chr(34) & " before
" & oRng & " on page " & Selection.Information(wdActiveEndPageNumber) & ".",
vbYesNoCancel, "Acroyms")
Case vbCancel
Exit Sub
Case vbYes
oRng.InsertBefore "the "
oRng.Collapse wdCollapseEnd
End Select
End If
End If
End With
End Select
Wend
End With
Set oRng = Nothing
Call h
Call col
Call LNoteColon
Call NoteColon
Call LNotehyphen
Call Notehyphen
Call LTipColon
Call TipColon
Call LTiphyphen
Call Tiphyphen
Selection.HomeKey wdStory
End Sub

Private Sub h()
Dim myRange As Range
Dim preRng As Range
Dim sCase As String
Set myRange = ActiveDocument.Range
With Selection
..HomeKey wdStory
With .Find
..ClearFormatting
..Replacement.ClearFormatting
Do While .Execute("- [A-Z]", MatchWildcards:=True)
Set myRange = Selection.Range
myRange.Start = myRange.End - 1
myRange.Select
Set preRng = Selection.Range
preRng.MoveStart wdWord, -5
'MsgBox preRng.Text
If InStr(1, preRng.Text, "Demonstration Screen") = 0 Then
If InStr(1, preRng.Text, "Match the Following") = 0 Then
If InStr(1, preRng.Text, "Sequencing") = 0 Then
If InStr(1, preRng.Text, "Multiple Choice Question") = 0 Then
sCase = MsgBox("The word after " & Chr(34) & "hyphen" & Chr(34) & " on page
" & Selection.Information(wdActiveEndPageNumber) & " should be in lower
case.", vbYesNoCancel)
If sCase = vbCancel Then
Exit Sub
End If
If sCase = vbYes Then myRange.Case = wdLowerCase
End If
End If
End If
End If
Selection.Collapse wdCollapseEnd
Loop
End With
End With
End Sub

Private Sub col()
Dim myRange As Range
Dim preRng As Range
Dim sCase As String
Set myRange = ActiveDocument.Range
With Selection
..HomeKey wdStory
With .Find
..ClearFormatting
..Replacement.ClearFormatting
Do While .Execute(": [A-Z]", MatchWildcards:=True)
Set myRange = Selection.Range
myRange.Start = myRange.End - 1
myRange.Select
Set preRng = Selection.Range
preRng.MoveStart wdWord, -3
'MsgBox preRng.Text
If InStr(1, preRng.Text, "Lesson Name") = 0 Then
If InStr(1, preRng.Text, "Lesson Number") = 0 Then
If InStr(1, preRng.Text, "RIO") = 0 Then
If InStr(1, preRng.Text, "Bloom's Level") = 0 Then
If InStr(1, preRng.Text, "On-screen Text") = 0 Then
If InStr(1, preRng.Text, "Graphics Elements") = 0 Then
If InStr(1, preRng.Text, "page Layout") = 0 Then
If InStr(1, preRng.Text, "page Description") = 0 Then
If InStr(1, preRng.Text, "Animation Audio") = 0 Then
If InStr(1, preRng.Text, "Animation Description") = 0 Then
If InStr(1, preRng.Text, "Prompt Text") = 0 Then
If InStr(1, preRng.Text, "Hyperlink/Popup Text Content") = 0 Then
If InStr(1, preRng.Text, "Objective Mapping") = 0 Then
If InStr(1, preRng.Text, "page #") = 0 Then
If InStr(1, preRng.Text, "Interactivity") = 0 Then
If InStr(1, preRng.Text, "Feedback/Tips") = 0 Then
If InStr(1, preRng.Text, "Notes to Developer") = 0 Then
If InStr(1, preRng.Text, "Screenshot") = 0 Then
If InStr(1, preRng.Text, "Question text") = 0 Then
If InStr(1, preRng.Text, "Version") = 0 Then
If InStr(1, preRng.Text, "Date") = 0 Then
sCase = MsgBox("The word after " & Chr(34) & "colon " & Chr(34) & "on page "
& Selection.Information(wdActiveEndPageNumber) & " should be in lower case.",
vbYesNoCancel, "Colon")
If sCase = vbCancel Then
Exit Sub
End If
If sCase = vbYes Then myRange.Case = wdLowerCase
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
Selection.Collapse wdCollapseEnd
Loop
End With
End With
End Sub





Private Sub LNoteColon()
Dim oRng As Range
Set oRng = ActiveDocument.Range
With oRng
With .Find
.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

Private Sub Notehyphen()
Dim oRng As Range
Set oRng = ActiveDocument.Range
With oRng
With .Find
.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) & "hyphen." & Chr(34), vbYesNoCancel, "Hyphen")
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


Private Sub LNotehyphen()
Dim oRng As Range
Set oRng = ActiveDocument.Range
With oRng
With .Find
.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) & "hyphen." & Chr(34), vbYesNoCancel, "Hyphen")
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



Private Sub NoteColon()
Dim oRng As Range
Set oRng = ActiveDocument.Range
With oRng
With .Find
.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




Private Sub LTipColon()
Dim oRng As Range
Set oRng = ActiveDocument.Range
With oRng
With .Find
.ClearFormatting
.Replacement.ClearFormatting
Do While .Execute("Tip: [A-Za-z]{1,}>", MatchWildcards:=True)
oRng.Select 'Word processing
Select Case MsgBox(Chr(34) & "Tip" & 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



Private Sub TipColon()
Dim oRng As Range
Set oRng = ActiveDocument.Range
With oRng
With .Find
.ClearFormatting
.Replacement.ClearFormatting
Do While .Execute("TIP: [A-Za-z]{1,}>", MatchWildcards:=True)
oRng.Select 'Word processing
Select Case MsgBox(Chr(34) & "Tip" & 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


Private Sub LTiphyphen()
Dim oRng As Range
Set oRng = ActiveDocument.Range
With oRng
With .Find
.ClearFormatting
.Replacement.ClearFormatting
Do While .Execute("Tip- [A-Za-z]{1,}>", MatchWildcards:=True)
oRng.Select 'Word processing
Select Case MsgBox(Chr(34) & "Tip" & Chr(34) & " on page " &
Selection.Information(wdActiveEndPageNumber) & " should not be followed by "
& Chr(34) & "hyphen." & Chr(34), vbYesNoCancel, "Hyphen")
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


Private Sub Tiphyphen()
Dim oRng As Range
Set oRng = ActiveDocument.Range
With oRng
With .Find
.ClearFormatting
.Replacement.ClearFormatting
Do While .Execute("TIP- [A-Za-z]{1,}>", MatchWildcards:=True)
oRng.Select 'Word processing
Select Case MsgBox(Chr(34) & "Tip" & Chr(34) & " on page " &
Selection.Information(wdActiveEndPageNumber) & " should not be followed by "
& Chr(34) & "hyphen." & Chr(34), vbYesNoCancel, "Hyphen")
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

The Word object model is quite different to the PowerPoint one. Much of your
code is word specific, some can be "translated" eg ActiveDocument >
ActivePresentation but others just don't exist in PowerPoint which does not
have the sophisticated text handling capability.
--
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 got this macro which i m tryin to run with power point. I m getting some
getting Compile Erro- User defined type not defined. But the macros work so
perfectly with Word. Whats the porblem can u help me out? Can someone help me
out.?

The code is displayed below. (I m sorry its a bit big- Thanks for the help)

Sub Led()
Dim oRng As Range
Dim oRngDup As Range
Dim rslt As VbMsgBoxResult
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = "<([A-Z]{2,})"
.MatchWildcards = True
.Wrap = wdFindStop
.Forward = True
While .Execute
oRng.Select
Select Case oRng.Text
'Exclude first case words.
Case Is = "TABLE", "OF", "RIO", "OST", "RLO", "NEXT", "CONTENTS",
"AUDIO", "TEXT", "NOTE", "TIP", "MCQ", "WILL", "TRADE", "OR"
oRng.Collapse wdCollapseEnd
'Process all other words
Case Else
Set oRngDup = oRng.Duplicate
With oRngDup
.Move wdCharacter, -5
.MoveEnd wdCharacter, 4
If Not .Text = "the " And Not .Text = "The " Then
If Not .Text = "THE " Then
Select Case MsgBox("Add " & Chr(34) & "the" & Chr(34) & " before
" & oRng & " on page " & Selection.Information(wdActiveEndPageNumber) & ".",
vbYesNoCancel, "Acroyms")
Case vbCancel
Exit Sub
Case vbYes
oRng.InsertBefore "the "
oRng.Collapse wdCollapseEnd
End Select
End If
End If
End With
End Select
Wend
End With
Set oRng = Nothing
Call h
Call col
Call LNoteColon
Call NoteColon
Call LNotehyphen
Call Notehyphen
Call LTipColon
Call TipColon
Call LTiphyphen
Call Tiphyphen
Selection.HomeKey wdStory
End Sub

Private Sub h()
Dim myRange As Range
Dim preRng As Range
Dim sCase As String
Set myRange = ActiveDocument.Range
With Selection
.HomeKey wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
Do While .Execute("- [A-Z]", MatchWildcards:=True)
Set myRange = Selection.Range
myRange.Start = myRange.End - 1
myRange.Select
Set preRng = Selection.Range
preRng.MoveStart wdWord, -5
'MsgBox preRng.Text
If InStr(1, preRng.Text, "Demonstration Screen") = 0 Then
If InStr(1, preRng.Text, "Match the Following") = 0 Then
If InStr(1, preRng.Text, "Sequencing") = 0 Then
If InStr(1, preRng.Text, "Multiple Choice Question") = 0 Then
sCase = MsgBox("The word after " & Chr(34) & "hyphen" & Chr(34) & " on page
" & Selection.Information(wdActiveEndPageNumber) & " should be in lower
case.", vbYesNoCancel)
If sCase = vbCancel Then
Exit Sub
End If
If sCase = vbYes Then myRange.Case = wdLowerCase
End If
End If
End If
End If
Selection.Collapse wdCollapseEnd
Loop
End With
End With
End Sub

Private Sub col()
Dim myRange As Range
Dim preRng As Range
Dim sCase As String
Set myRange = ActiveDocument.Range
With Selection
.HomeKey wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
Do While .Execute(": [A-Z]", MatchWildcards:=True)
Set myRange = Selection.Range
myRange.Start = myRange.End - 1
myRange.Select
Set preRng = Selection.Range
preRng.MoveStart wdWord, -3
'MsgBox preRng.Text
If InStr(1, preRng.Text, "Lesson Name") = 0 Then
If InStr(1, preRng.Text, "Lesson Number") = 0 Then
If InStr(1, preRng.Text, "RIO") = 0 Then
If InStr(1, preRng.Text, "Bloom's Level") = 0 Then
If InStr(1, preRng.Text, "On-screen Text") = 0 Then
If InStr(1, preRng.Text, "Graphics Elements") = 0 Then
If InStr(1, preRng.Text, "page Layout") = 0 Then
If InStr(1, preRng.Text, "page Description") = 0 Then
If InStr(1, preRng.Text, "Animation Audio") = 0 Then
If InStr(1, preRng.Text, "Animation Description") = 0 Then
If InStr(1, preRng.Text, "Prompt Text") = 0 Then
If InStr(1, preRng.Text, "Hyperlink/Popup Text Content") = 0 Then
If InStr(1, preRng.Text, "Objective Mapping") = 0 Then
If InStr(1, preRng.Text, "page #") = 0 Then
If InStr(1, preRng.Text, "Interactivity") = 0 Then
If InStr(1, preRng.Text, "Feedback/Tips") = 0 Then
If InStr(1, preRng.Text, "Notes to Developer") = 0 Then
If InStr(1, preRng.Text, "Screenshot") = 0 Then
If InStr(1, preRng.Text, "Question text") = 0 Then
If InStr(1, preRng.Text, "Version") = 0 Then
If InStr(1, preRng.Text, "Date") = 0 Then
sCase = MsgBox("The word after " & Chr(34) & "colon " & Chr(34) & "on page "
& Selection.Information(wdActiveEndPageNumber) & " should be in lower case.",
vbYesNoCancel, "Colon")
If sCase = vbCancel Then
Exit Sub
End If
If sCase = vbYes Then myRange.Case = wdLowerCase
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
Selection.Collapse wdCollapseEnd
Loop
End With
End With
End Sub





Private Sub LNoteColon()
Dim oRng As Range
Set oRng = ActiveDocument.Range
With oRng
With .Find
.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

Private Sub Notehyphen()
Dim oRng As Range
Set oRng = ActiveDocument.Range
With oRng
With .Find
.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) & "hyphen." & Chr(34), vbYesNoCancel, "Hyphen")
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


Private Sub LNotehyphen()
Dim oRng As Range
Set oRng = ActiveDocument.Range
With oRng
With .Find
.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) & "hyphen." & Chr(34), vbYesNoCancel, "Hyphen")
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



Private Sub NoteColon()
Dim oRng As Range
Set oRng = ActiveDocument.Range
With oRng
With .Find
.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




Private Sub LTipColon()
Dim oRng As Range
Set oRng = ActiveDocument.Range
With oRng
With .Find
.ClearFormatting
.Replacement.ClearFormatting
Do While .Execute("Tip: [A-Za-z]{1,}>", MatchWildcards:=True)
oRng.Select 'Word processing
Select Case MsgBox(Chr(34) & "Tip" & 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
 

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

Similar Threads

Errors 3
Macros to delete em dashs 3
VBA Coding Help for Beginner 0
Illogical Errorq 1
can someone tell me why i m facing this error 5
VBA Export to PDF 0
Prefixing errror 1
Extract name, address and ph# 8

Top