PC Review


Reply
Thread Tools Rate Thread

code to find colon in text placeholder?

 
 
Geoff Cox
Guest
Posts: n/a
 
      8th Jun 2006
Hello,

I am trying to search multiple ppt files to find a few cases where
there is a colon in a text placeholder (type 14). I would like to be
able to view the slides which have the colon.

Can anyone please point me at macro code which tackles this kind of
action?

The code below will find an action button on any slide - perhaps this
could be changed to find the colon??

I am not clear how the

If .Shapes.Count > 0 Then

would be changed to cope with looking for a colon within a text
placeholder ....

Thanks

Geoff


Sub MyMacro(strMyFile As String)
' this gets called once for each file that meets the spec you enter in
ForEachPresentation
' strMyFile is set to the file name each time

' Probably at a minimum, you'd want to:
Dim oPresentation As Presentation
Set oPresentation = Presentations.Open(strMyFile)

With oPresentation


Dim oSh As shape
Dim bFoundButton As Boolean
Dim bFoundRectangle As Boolean

bFoundButton = False ' to start

With ActivePresentation.Slides(ActivePresentation.Slides.Count)

If .Shapes.Count > 0 Then

For Each oSh In _
ActivePresentation.Slides(ActivePresentation.Slides.Count) _
.Shapes
If oSh.Type = 1 Then
If oSh.AutoShapeType = 130 Then
bFoundButton = True
End If
End If
Next

' Now display a message
' If bFoundButton Then
' MsgBox "Found a Forward or Next button on the last slide"
'Else
' MsgBox "No Forward/Next buttons here"
'End If

If Not bFoundButton Then
MsgBox "No button on last slide of " & strMyFile
End If

Else
MsgBox "No shape on this last slide in " & strMyFile
End If

End With

oPresentation.Close


End With
Set oSh = Nothing
Set oPresentation = Nothing

End Sub


 
Reply With Quote
 
 
 
 
Geoff Cox
Guest
Posts: n/a
 
      8th Jun 2006
On Thu, 08 Jun 2006 07:24:55 +0100, Geoff Cox
<(E-Mail Removed)> wrote:


trying to make a little head way myself I have following code which
does find and select text placeholders but then comes up with an error
message re Shape (unknown member) and "to select a shape its view must
be active". How do I make it active?

Also how do I search for the colon within the text placeholder?

Geoff


Sub MyMacro(strMyFile As String)

Dim oPresentation As Presentation
Set oPresentation = Presentations.Open(strMyFile)

With oPresentation

Dim oSl As Slide
Dim foundTextPlaceHolder As Boolean
foundTextPlaceHolder = False


For Each oSl In ActivePresentation.Slides

Dim oSh As shape
'On Error GoTo ErrorHandler

For Each oSh In oSl.Shapes

If oSh.Type = 14 Then

oSh.Select

foundTextPlaceHolder = True
MsgBox "text placeholder found in " & strMyFile

End If

Next oSh

Next oSl

oPresentation.Close

End With
Set oSh = Nothing
Set oPresentation = Nothing

End Sub




 
Reply With Quote
 
=?Utf-8?B?Sm9obiBXaWxzb24=?=
Guest
Posts: n/a
 
      8th Jun 2006
Geoff

If shapes.count > 0
This just checks that there are some shapes on the slide.

Try this code and see if its what you need ( or maybe use it as a starting
point)

Checks all shapes on all slides > Is it a type 14 shape? If yes checks text
for a colon and reports each slide number with colons in turn.
'code starts
Sub Findcolon()

Dim oSld As Slide
Dim oShp As Shape
Dim strtext As String
Dim strchr As String

For Each oSld In ActivePresentation.Slides
For Each oShp In oSld.Shapes
If oShp.Type = 14 Then
strtext = oShp.TextFrame.TextRange
For c = 1 To Len(strtext)
strchr = Mid$(strtext, c, 1)
If strchr = ":" Then MsgBox ("found on slide " & oSld.SlideNumber)
Next c
End If
Next oShp
Next oSld
End Sub
'code ends
--
-----------------------------------------
Did that answer the question / help?
_____________________________
John Wilson
Microsoft Certified Office Specialist



"Geoff Cox" wrote:

> On Thu, 08 Jun 2006 07:24:55 +0100, Geoff Cox
> <(E-Mail Removed)> wrote:
>
>
> trying to make a little head way myself I have following code which
> does find and select text placeholders but then comes up with an error
> message re Shape (unknown member) and "to select a shape its view must
> be active". How do I make it active?
>
> Also how do I search for the colon within the text placeholder?
>
> Geoff
>
>
> Sub MyMacro(strMyFile As String)
>
> Dim oPresentation As Presentation
> Set oPresentation = Presentations.Open(strMyFile)
>
> With oPresentation
>
> Dim oSl As Slide
> Dim foundTextPlaceHolder As Boolean
> foundTextPlaceHolder = False
>
>
> For Each oSl In ActivePresentation.Slides
>
> Dim oSh As shape
> 'On Error GoTo ErrorHandler
>
> For Each oSh In oSl.Shapes
>
> If oSh.Type = 14 Then
>
> oSh.Select
>
> foundTextPlaceHolder = True
> MsgBox "text placeholder found in " & strMyFile
>
> End If
>
> Next oSh
>
> Next oSl
>
> oPresentation.Close
>
> End With
> Set oSh = Nothing
> Set oPresentation = Nothing
>
> End Sub
>
>
>
>
>

 
Reply With Quote
 
Geoff Cox
Guest
Posts: n/a
 
      8th Jun 2006
On Thu, 8 Jun 2006 01:06:01 -0700, John Wilson <codepeople AT aol DOT
com> wrote:

John,

Thanks for your code ideas - I have tried following but get a runtime
error message,

TextFrame(unknown member): Invalid request. This type of shape cannot
have a TextRange.

Debug points at

strtext = sHp.TextFrame.TextRange

Any thoughts?!

Cheers

Geoff

Sub MyMacro(strMyFile As String)

Dim oPresentation As Presentation
Set oPresentation = Presentations.Open(strMyFile)

With oPresentation

Dim oSld As Slide
Dim oShp As shape
Dim strtext As String
Dim strchr As String

For Each oSld In ActivePresentation.Slides
For Each oShp In oSld.Shapes
If oShp.Type = 14 Then
strtext = oShp.TextFrame.TextRange
For c = 1 To Len(strtext)
strchr = Mid$(strtext, c, 1)
If strchr = ":" Then MsgBox ("found on slide " & _
oSld.SlideNumber)
Next c
End If
Next oShp
Next oSld

oPresentation.Close


Set oSh = Nothing
Set oPresentation = Nothing

End With

End Sub
 
Reply With Quote
 
Geoff Cox
Guest
Posts: n/a
 
      8th Jun 2006
On Thu, 8 Jun 2006 01:06:01 -0700, John Wilson <codepeople AT aol DOT
com> wrote:


John,

Have found that the error message can be avoided using " On Error
Resume Next" etc.

Cheers

Geoff





For Each oSld In ActivePresentation.Slides
For Each oShp In oSld.Shapes
If oShp.Type = 14 Then

On Error Resume Next

strtext = oShp.TextFrame.TextRange

For c = 1 To Len(strtext)
strchr = Mid$(strtext, c, 1)
If strchr = ":" Then MsgBox ("found on slide " &
oSld.SlideNumber & " in " & strMyFile)
Next c
End If

On Error GoTo 0

Next oShp
Next oSld
 
Reply With Quote
 
=?Utf-8?B?Sm9obiBXaWxzb24=?=
Guest
Posts: n/a
 
      8th Jun 2006
Debug points at
"strtext = sHp.TextFrame.TextRange "
Note this isnt what my code said!

If this is just a spelling mistake you could maybe try this ammendment

Sub findcolons()
Dim oSld As Slide
Dim oShp As Shape
Dim strtext As String
Dim strchr As String

For Each oSld In ActivePresentation.Slides
For Each oShp In oSld.Shapes
If oShp.HasTextFrame Then
If oShp.Type = msoPlaceholder Then
strtext = oShp.TextFrame.TextRange
For c = 1 To Len(strtext)
strchr = Mid$(strtext, c, 1)
If strchr = ":" Then MsgBox ("found on slide " & oSld.SlideNumber)
Next c
End If
End If
Next oShp
Next oSld
End Sub
--
-----------------------------------------
Did that answer the question / help?
_____________________________
John Wilson
Microsoft Certified Office Specialist



"Geoff Cox" wrote:

> On Thu, 8 Jun 2006 01:06:01 -0700, John Wilson <codepeople AT aol DOT
> com> wrote:
>
> John,
>
> Thanks for your code ideas - I have tried following but get a runtime
> error message,
>
> TextFrame(unknown member): Invalid request. This type of shape cannot
> have a TextRange.
>
> Debug points at
>
> strtext = sHp.TextFrame.TextRange
>
> Any thoughts?!
>
> Cheers
>
> Geoff
>
> Sub MyMacro(strMyFile As String)
>
> Dim oPresentation As Presentation
> Set oPresentation = Presentations.Open(strMyFile)
>
> With oPresentation
>
> Dim oSld As Slide
> Dim oShp As shape
> Dim strtext As String
> Dim strchr As String
>
> For Each oSld In ActivePresentation.Slides
> For Each oShp In oSld.Shapes
> If oShp.Type = 14 Then
> strtext = oShp.TextFrame.TextRange
> For c = 1 To Len(strtext)
> strchr = Mid$(strtext, c, 1)
> If strchr = ":" Then MsgBox ("found on slide " & _
> oSld.SlideNumber)
> Next c
> End If
> Next oShp
> Next oSld
>
> oPresentation.Close
>
>
> Set oSh = Nothing
> Set oPresentation = Nothing
>
> End With
>
> End Sub
>

 
Reply With Quote
 
David M. Marcovitz
Guest
Posts: n/a
 
      8th Jun 2006
Geoff Cox <(E-Mail Removed)> wrote in
news:(E-Mail Removed):

> If oShp.Type = 14 Then
>


What about:

If oShp.Type = 14 And oShp.HasTextFrame Then

--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
Reply With Quote
 
=?Utf-8?B?Sm9obiBXaWxzb24=?=
Guest
Posts: n/a
 
      8th Jun 2006
Both these do pretty well the same job (though DM's is neater!)

The problem is that type 14 shapes include placeholders that cannot have a
text frame (eg picture holders), I guess your presentation had such a
placeholder which would cause the error.
--
-----------------------------------------
Did that answer the question / help?
_____________________________
John Wilson
Microsoft Certified Office Specialist



"Geoff Cox" wrote:

> On Thu, 8 Jun 2006 01:06:01 -0700, John Wilson <codepeople AT aol DOT
> com> wrote:
>
> John,
>
> Thanks for your code ideas - I have tried following but get a runtime
> error message,
>
> TextFrame(unknown member): Invalid request. This type of shape cannot
> have a TextRange.
>
> Debug points at
>
> strtext = sHp.TextFrame.TextRange
>
> Any thoughts?!
>
> Cheers
>
> Geoff
>
> Sub MyMacro(strMyFile As String)
>
> Dim oPresentation As Presentation
> Set oPresentation = Presentations.Open(strMyFile)
>
> With oPresentation
>
> Dim oSld As Slide
> Dim oShp As shape
> Dim strtext As String
> Dim strchr As String
>
> For Each oSld In ActivePresentation.Slides
> For Each oShp In oSld.Shapes
> If oShp.Type = 14 Then
> strtext = oShp.TextFrame.TextRange
> For c = 1 To Len(strtext)
> strchr = Mid$(strtext, c, 1)
> If strchr = ":" Then MsgBox ("found on slide " & _
> oSld.SlideNumber)
> Next c
> End If
> Next oShp
> Next oSld
>
> oPresentation.Close
>
>
> Set oSh = Nothing
> Set oPresentation = Nothing
>
> End With
>
> End Sub
>

 
Reply With Quote
 
Steve Rindsberg
Guest
Posts: n/a
 
      8th Jun 2006

Note that you can simplify this:

> strtext = oShp.TextFrame.TextRange
>
> For c = 1 To Len(strtext)
> strchr = Mid$(strtext, c, 1)
> If strchr = ":" Then MsgBox ("found on slide " &
> oSld.SlideNumber & " in " & strMyFile)
> Next c
> End If


to

If Instr(oShp.TextFrame.TextRange,":") > 0 Then
' the text has been colonized
End If



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


 
Reply With Quote
 
=?Utf-8?B?Sm9obiBXaWxzb24=?=
Guest
Posts: n/a
 
      8th Jun 2006
Thanks Steve - stored in "lessons learned today" box!!!

_____________________________
John



"Steve Rindsberg" wrote:

>
> Note that you can simplify this:
>
> > strtext = oShp.TextFrame.TextRange
> >
> > For c = 1 To Len(strtext)
> > strchr = Mid$(strtext, c, 1)
> > If strchr = ":" Then MsgBox ("found on slide " &
> > oSld.SlideNumber & " in " & strMyFile)
> > Next c
> > End If

>
> to
>
> If Instr(oShp.TextFrame.TextRange,":") > 0 Then
> ' the text has been colonized
> End If
>
>
>
> -----------------------------------------
> Steve Rindsberg, PPT MVP
> PPT FAQ: www.pptfaq.com
> PPTools: www.pptools.com
> ================================================
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RE: What does the semi-colon do in vba code? OssieMac Microsoft Access VBA Modules 0 9th Nov 2009 04:54 AM
Re: What does the semi-colon do in vba code? Marshall Barton Microsoft Access VBA Modules 0 7th Nov 2009 08:24 PM
how to change colon to semi-colon in CP/List Seprator Khoshravan Microsoft Excel Misc 3 4th Feb 2009 07:41 PM
Placeholder in find code keri Microsoft Excel Programming 3 13th Apr 2007 03:02 PM
Colon in code? davegb Microsoft Excel Programming 5 13th Jan 2006 04:09 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:01 PM.