Search text in powerpoint slides

haplc

Board Regular
Joined
May 27, 2004
Messages
71
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
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
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:
Upvote 0
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top