Search text in powerpoint slides

haplc

Board Regular
Joined
May 27, 2004
Messages
59
Dear All

I have to search slides in presentation "400.pptx" which contains a word , lets say "pumping". I have developed user form in power point "Sel_ppt..pptm". IN the user form, user can enter any word and the macro is searching slides in 400.ppt. If there is any slide containining "pumping" then it copies that slide into "sel_pptx".
Issue is if the user key in "pumping" instead of "Pumping" then the macro is not able to select slide even if contains "Pumping".
How to ensure that the search should check for "pumping" regardess of case used?

Here is the code:

VWcard is a text field in userform2
VWCard = "*" & UserForm2.WCard.Value & "*" 'Text field in userform in which user can key in search word

Here the word given in VWCard is being searched in different shapes in every slide of the power point "400.pptx"

If (PowerPoint.Application.Presentations("400.pptx").Slides(NRow).Shapes(1).TextFrame.TextRange.Text Like "" & VWCard & "") Or (PowerPoint.Application.Presentations("400.pptx").Slides(NRow).Shapes(2).TextFrame.TextRange.Text Like "" & VWCard & "") Or (PowerPoint.Application.Presentations("400.pptx").Slides(NRow).Shapes(3).TextFrame.TextRange.Text Like "" & VWCard & "") Or (PowerPoint.Application.Presentations("400.pptx").Slides(NRow).Shapes(11).TextFrame.TextRange.Text Like "" & VWCard & "") Or _
(PowerPoint.Application.Presentations("400.pptx").Slides(NRow).Shapes(4).TextFrame.TextRange.Text Like "" & VWCard & "") Or (PowerPoint.Application.Presentations("400.pptx").Slides(NRow).Shapes(8).TextFrame.TextRange.Text Like "" & VWCard & "") Or (PowerPoint.Application.Presentations("400.pptx").Slides(NRow).Shapes(12).TextFrame.TextRange.Text Like "" & VWCard & "") Or (PowerPoint.Application.Presentations("400.pptx").Slides(NRow).Shapes(15).TextFrame.TextRange.Text Like "" & VWCard & "") Then

PowerPoint.Application.Presentations("C:\OEM\SST\400.pptx").Slides(NRow).Copy
'pres2.Slides.Paste pres2.Slides.Count + 1
With pres1.Slides.Paste
.ColorScheme = PowerPoint.Application.Presentations("C:\OEM\SST\400.pptx").Slides(NRow).ColorScheme

End With
 

Domenic

MrExcel MVP
Joined
Mar 10, 2004
Messages
19,003
Try...

Code:
If [COLOR=#ff0000]UCase[/COLOR](PowerPoint.Application.Presentations("400.pptx").Slides(NRow).Shapes(1).TextFrame.TextRange.Text) Like [COLOR=#ff0000]UCase[/COLOR](VWCard) Or
Although, you could replace...

Code:
VWCard = "*" & UserForm2.WCard.Value & "*"
with

Code:
VWCard = UserForm2.WCard.Value
Then you would have the following instead...

Code:
If [COLOR=#ff0000]UCase[/COLOR](PowerPoint.Application.Presentations("400.pptx").Slides(NRow).Shapes(1).TextFrame.TextRange.Text) Like [COLOR=#ff0000]"*" & UCase(VWCard) & "*"[/COLOR] Or
This way, if needed, you can refer to VWCard in other parts of your code without having the asterisk prepended and appended.

Hope this helps!
 
Last edited:

haplc

Board Regular
Joined
May 27, 2004
Messages
59
Dear Domenic,

Many thanks. However, I tried both codes but the results is it is not detecting the search word if it is not written as it is written in slides. I am using powerpoint 2016.

Can you please look into the code again?

THanks
 

haplc

Board Regular
Joined
May 27, 2004
Messages
59
Oh....sorryy

Was my mistake. I did not put the code with second presentation I have to make search in. Working perfectly fine now..thanks
 

Forum statistics

Threads
1,081,556
Messages
5,359,547
Members
400,533
Latest member
fpenning

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top