Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General PowerPoint Questions / July 2007

Tip: Looking for answers? Try searching our database.

Spped of searching

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Marcw - 18 Jul 2007 20:07 GMT
I have recently ported some VBA code that checks Word documents for
misspellings, incorrect terminology, etc. to PowerPoint and discovered
the limitations of the PPT object model compared to Word. I am looping
through the presentations by Slide, Shape, looking for TextFrames and
TextRanges, etc.  for both slides and Notes and have found the entire
process to be extremely slow.

There are about 950 rules being processed. My test presentation is 19
slides with notes on just about each page and takes 10-12 minutes.  In
Word checking a 54 page document took a little over 2 minutes. The
Notes checking appears to be taking the most time, but there is a lot
of text in these notes.

Are there any hints on speeding this up?

Here's the relevant code:

Private Function myFind(SlideNum As Integer, ShapeNumber As Integer,
ViewType As Integer) As Boolean

       Set sld = Application.ActivePresentation.Slides(nSld)
       If ActiveWindow.ViewType = ppViewNotesPage Then GoTo NotesPage
       ActiveWindow.ViewType = ppViewSlide
       ' Loop through each shape on each slide.
       For nShp = ShapeNumber To sld.Shapes.Count
           Set shp = sld.Shapes(nShp)
           If shp.HasTextFrame And shp.TextFrame.HasText Then
               Set txtRng = shp.TextFrame.TextRange
               Set foundText = txtRng.Find(FindWhat:=sFrom,
MatchCase:=CaseSens, WholeWords:=IsAlpha(sFrom))
               If Not (foundText Is Nothing) Then
                   If sTo <> "count" Then ScreenUpdating = True
                   ActiveWindow.View.GotoSlide index:=sld.SlideIndex
                   foundText.Select
                   myFind = True
                   ShapeType = Slide
                   If sTo = "count" Then
                       lcv = lcv + 1
                       Do While Not (foundText Is Nothing)
                           With foundText
                               Set foundText =
txtRng.Find(FindWhat:=sFrom, After:=.Start, _
                                       MatchCase:=CaseSens,
WholeWords:=IsAlpha(sFrom))
                               If Not (foundText Is Nothing) Then
                                   lcv = lcv + 1
                               End If
                           End With
                       Loop
                   Else
                       ScreenUpdating = True
                       Exit Function
                   End If
               End If
           End If
       Next nShp
NotesPage:
       If ActiveWindow.ViewType = ppViewSlide Then
           ShapeNumber = 1
           ActiveWindow.ViewType = ppViewNotesPage
       End If
       ' Loop through each shape on each slide.
       For nShp = ShapeNumber To sld.NotesPage.Shapes.Count
           Set shp = sld.NotesPage.Shapes(nShp)
           If shp.PlaceholderFormat.Type = ppPlaceholderBody Then
               If shp.HasTextFrame And shp.TextFrame.HasText Then
                   Set txtRng = shp.TextFrame.TextRange
                   Set foundText = txtRng.Find(FindWhat:=sFrom,
MatchCase:=CaseSens, WholeWords:=IsAlpha(sFrom))
                   If Not (foundText Is Nothing) Then
                       If sTo <> "count" Then ScreenUpdating = True
                       ActiveWindow.View.GotoSlide
index:=sld.SlideIndex
                       foundText.Select
                       myFind = True
                       ShapeType = Note
                       If sTo = "count" Then
                           lcv = lcv + 1
                           Do While Not (foundText Is Nothing)
                               With foundText
                                   Set foundText =
txtRng.Find(FindWhat:=sFrom, After:=.Start, _
                                           MatchCase:=CaseSens,
WholeWords:=IsAlpha(sFrom))
                                   If Not (foundText Is Nothing) Then
                                       lcv = lcv + 1
                                   End If
                               End With
                           Loop
                       Else
                           ScreenUpdating = True
                           Exit Function
                       End If
                   End If
               End If
           End If
       Next nShp
       ActiveWindow.ViewType = ppViewSlide
   Next nSld

Thanks,

Marc Wiener
Gartner, Inc.
Austin Myers - 19 Jul 2007 19:26 GMT
I have found its much quicker to call the Office (word) spell checker.  You
might want to look at this KB article.

http://support.microsoft.com/kb/243844/en-us

Austin Myers
MS PowerPoint MVP Team

Provider of PFCPro, PFCMedia and PFCExpress
www.playsforcertain.com

>I have recently ported some VBA code that checks Word documents for
> misspellings, incorrect terminology, etc. to PowerPoint and discovered
[quoted text clipped - 100 lines]
> Marc Wiener
> Gartner, Inc.
Marc Wiener - 23 Jul 2007 18:37 GMT
Thanks, but this is not a simple spell check, but a series of rules that
follow our style guide.

Marc

>I have found its much quicker to call the Office (word) spell checker.  You
> might want to look at this KB article.
[quoted text clipped - 111 lines]
>> Marc Wiener
>> Gartner, Inc.
Steve Rindsberg - 20 Jul 2007 21:45 GMT
> I have recently ported some VBA code that checks Word documents for
> misspellings, incorrect terminology, etc. to PowerPoint and discovered
[quoted text clipped - 12 lines]
>
> Here's the relevant code:

Hi Marc, how's it going.  Apart from this, that is?  <g>
Now as to this:

> Private Function myFind(SlideNum As Integer, ShapeNumber As Integer,
> ViewType As Integer) As Boolean

Internally, all of these things are VB/VBA Longs, not Integers.
Treating them as integers will work, but will be marginally slower and may rear
back and bite you some day in a later version.  Better to use Longs instead.

>         Set sld = Application.ActivePresentation.Slides(nSld)
>         If ActiveWindow.ViewType = ppViewNotesPage Then GoTo NotesPage
>         ActiveWindow.ViewType = ppViewSlide

No need to change the view or go to slide if you're not going to use .Select,
and as noted below, don't use .Select

That alone should speed things up hugely.

>         ' Loop through each shape on each slide.
>         For nShp = ShapeNumber To sld.Shapes.Count
[quoted text clipped - 7 lines]
>                     ActiveWindow.View.GotoSlide index:=sld.SlideIndex
>                     foundText.Select

Avoid .Select like the plague.
Declare an object variable of the appropriate type and set a reference to it
instead, then use the variable instead of the selection.

You've already done that (foundText).  Why Select it?

>                     myFind = True
>                     ShapeType = Slide
[quoted text clipped - 18 lines]
>             End If
>         Next nShp

Same deal here. Don't select, don't change view, don't go to slide

> NotesPage:
>         If ActiveWindow.ViewType = ppViewSlide Then
[quoted text clipped - 44 lines]
> Marc Wiener
> Gartner, Inc.

-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ:  www.pptfaq.com
PPTools:  www.pptools.com
================================================
Marc Wiener - 23 Jul 2007 16:48 GMT
Hi Steve, things are well. Sorry about this double posting. I posted through
Google groups and for some reason did  not seeing the post. After a day I
reposted and was able to see it, but now it has again disappeared. No clue
what's going on, but I've now resorted to using Outlook Express.

Anyway, I've changed my ints to longs. Thanks for that, I was lazy and
didn't look it up.

As to the selects, this is an interactive application. When we find an item
in our rules list, we need to present it to the Editor who decides whether
or not to make the change, skip the instance or skip the rule according to
our style guide, e.g., Cost Benefit Analysis should be Cost-Benefit
Analysis. As the find itself does not highlight the term, I used select (and
changed the view, etc.). Is there another way of getting the same result
without the detriment of selecting? I would much prefer not having to
select, obviously.

Thanks as always,

Marc

>> I have recently ported some VBA code that checks Word documents for
>> misspellings, incorrect terminology, etc. to PowerPoint and discovered
[quoted text clipped - 133 lines]
> PPTools:  www.pptools.com
> ================================================
Steve Rindsberg - 23 Jul 2007 19:29 GMT
> Hi Steve, things are well. Sorry about this double posting.

No problem.  I wasn't scolding, just too lazy to look my other answer and post
again. <g>

> As to the selects, this is an interactive application. When we find an item
> in our rules list, we need to present it to the Editor who decides whether
> or not to make the change, skip the instance or skip the rule according to
> our style guide

OK.  That falls into the "when you have to" side of "unless you have to".

You pretty much have to show them the context of the text in order for them to
make an informed decision.

But what about going to the slide in slide view then displaying the text on a
user form instead?  In several text boxes, perhaps?

- All of the text from the shape in question (inactive so it can't be edited)

- The specific offending text the rule's called on the carpet (editable,
perhaps?)

- Proposed change to the text

- Buttons for Accept, Reject, etc

Another possibility is to lose the built in text finder and try replacing it
with your own (look at each shape, test to see if it has a text frame, if the
text frame has text, etc, then use Instr to see if your search text is present
in the shape's text.

, e.g., Cost Benefit Analysis should be Cost-Benefit
> Analysis. As the find itself does not highlight the term, I used select (and
> changed the view, etc.). Is there another way of getting the same result
[quoted text clipped - 142 lines]
> > PPTools:  www.pptools.com
> > ================================================

-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ:  www.pptfaq.com
PPTools:  www.pptools.com
================================================
Marc Wiener - 23 Jul 2007 19:46 GMT
Steve,

No problem, I didn't think you were scolding. Anyway, you made me think
about this again and I made a one line change that improved efficiency
enormously. I moved the  ActiveWindow.ViewType = ppViewNotesPage down in the
loop so it only gets called when a find is made. Run time is now greatly
imroved and makes this utility viable. I appreciate the prodding to make me
think :-) I'm getting lazier in my old age.

Marc

>> Hi Steve, things are well. Sorry about this double posting.
>
[quoted text clipped - 197 lines]
> PPTools:  www.pptools.com
> ================================================
Steve Rindsberg - 24 Jul 2007 02:11 GMT
> Steve,
>
[quoted text clipped - 4 lines]
> imroved and makes this utility viable. I appreciate the prodding to make me
> think :-) I'm getting lazier in my old age.

Heh!  I know *that* feeling.  Coffee doesn't do it in the AM any more.  Herself
has to get out the electrodes. ZZZZZZZI'M UP I'M UP!

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

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.