Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-17-2021, 06:35 PM
rupd911 rupd911 is offline How to delete a powerpoint slide based on keywords in the "Notes" field? Windows 10 How to delete a powerpoint slide based on keywords in the "Notes" field? Office 2016
Novice
How to delete a powerpoint slide based on keywords in the "Notes" field?
 
Join Date: Feb 2021
Posts: 4
rupd911 is on a distinguished road
Post How to delete a powerpoint slide based on keywords in the "Notes" field?

Hello everyone,



Can someone help me with this:

Problem Statement: I have a powerpoint file with several hundred slides and each slide has some notes in the Notes field. I also have another text file which has a number of keywords. The idea is to develop an automation script that can read the text file and delete all the slides in the powerpoint where one of the words in the notes field matches the keyword.

Thanks,
RUPD
Reply With Quote
  #2  
Old 02-18-2021, 07:10 AM
JohnWilson JohnWilson is offline How to delete a powerpoint slide based on keywords in the "Notes" field? Windows 10 How to delete a powerpoint slide based on keywords in the "Notes" field? Office 2016
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,912
JohnWilson has a spectacular aura aboutJohnWilson has a spectacular aura about
Default

This should at least give you a start. Make sure you keep a copy of the original!! Obviously change the path to the text file.

Code:
Sub Read_Txt_and_Check()

Dim fileNum As Integer
Dim RayTxt() As String
Dim L As Long
Dim T As Long
Dim b_Found As Boolean

fileNum = FreeFile
Open "C:\Users\info\Desktop\text.txt" For Input As fileNum
ReDim RayTxt(0)
Do While Not EOF(fileNum)
    ReDim Preserve RayTxt(UBound(RayTxt) + 1)
    Line Input #fileNum, RayTxt(UBound(RayTxt))
Loop
Close #fileNum

For L = ActivePresentation.Slides.Count To 1 Step -1
b_Found = False
For T = LBound(RayTxt) To UBound(RayTxt)
If word_Found(RayTxt(T), ActivePresentation.Slides(L).NotesPage.Shapes(2).TextFrame.TextRange) Then
b_Found = True
Exit For
End If
Next T
If b_Found Then ActivePresentation.Slides(L).Delete
Next L
End Sub

Function word_Found(strword As String, otxtR As TextRange) As Boolean
On Error Resume Next
Dim found As TextRange
Set found = otxtR.Find(FindWhat:=strword, MatchCase:=False, Wholewords:=True)
If Not found Is Nothing Then word_Found = True
End Function
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote
  #3  
Old 02-18-2021, 01:02 PM
macropod's Avatar
macropod macropod is offline How to delete a powerpoint slide based on keywords in the "Notes" field? Windows 10 How to delete a powerpoint slide based on keywords in the "Notes" field? Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Cross-posted (and answered before posting here) at: Extract first line of notes section on each slide - how to?
For cross-posting etiquette, please read: Excelguru Help Site - A message to forum cross posters
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #4  
Old 02-18-2021, 01:43 PM
JohnWilson JohnWilson is offline How to delete a powerpoint slide based on keywords in the "Notes" field? Windows 10 How to delete a powerpoint slide based on keywords in the "Notes" field? Office 2016
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,912
JohnWilson has a spectacular aura aboutJohnWilson has a spectacular aura about
Default

Not quite the same question though.
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote
  #5  
Old 02-18-2021, 01:49 PM
macropod's Avatar
macropod macropod is offline How to delete a powerpoint slide based on keywords in the "Notes" field? Windows 10 How to delete a powerpoint slide based on keywords in the "Notes" field? Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Initially, no. However, by the end of the thread at VBAX it's clear that the OP is seeking a solution to the same problem on both forums.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #6  
Old 02-18-2021, 08:52 PM
rupd911 rupd911 is offline How to delete a powerpoint slide based on keywords in the "Notes" field? Windows 10 How to delete a powerpoint slide based on keywords in the "Notes" field? Office 2016
Novice
How to delete a powerpoint slide based on keywords in the "Notes" field?
 
Join Date: Feb 2021
Posts: 4
rupd911 is on a distinguished road
Default

Quote:
Originally Posted by JohnWilson View Post
This should at least give you a start. Make sure you keep a copy of the original!! Obviously change the path to the text file.

Code:
Sub Read_Txt_and_Check()

Dim fileNum As Integer
Dim RayTxt() As String
Dim L As Long
Dim T As Long
Dim b_Found As Boolean

fileNum = FreeFile
Open "C:\Users\info\Desktop\text.txt" For Input As fileNum
ReDim RayTxt(0)
Do While Not EOF(fileNum)
    ReDim Preserve RayTxt(UBound(RayTxt) + 1)
    Line Input #fileNum, RayTxt(UBound(RayTxt))
Loop
Close #fileNum

For L = ActivePresentation.Slides.Count To 1 Step -1
b_Found = False
For T = LBound(RayTxt) To UBound(RayTxt)
If word_Found(RayTxt(T), ActivePresentation.Slides(L).NotesPage.Shapes(2).TextFrame.TextRange) Then
b_Found = True
Exit For
End If
Next T
If b_Found Then ActivePresentation.Slides(L).Delete
Next L
End Sub

Function word_Found(strword As String, otxtR As TextRange) As Boolean
On Error Resume Next
Dim found As TextRange
Set found = otxtR.Find(FindWhat:=strword, MatchCase:=False, Wholewords:=True)
If Not found Is Nothing Then word_Found = True
End Function
Thanks a ton! this worked like magic !!
Reply With Quote
Reply

Tags
automation, delete a page, notes field

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to view the names of "linked" contacts under the notes field ChairPotato Outlook 0 04-24-2020 12:55 PM
Error: "Changes made were lost...reconnect with server", when switching "from" field randhurrle Outlook 2 02-25-2015 06:51 PM
How do I delete the names under "Exceptions" when I use the "Restrict Editing" feature in Word? MengS Word 0 02-25-2015 02:57 PM
How to delete a powerpoint slide based on keywords in the "Notes" field? disappearing content of the "Notes" field in different views heiterbiswolkig Project 3 05-19-2014 07:28 AM
How to delete a powerpoint slide based on keywords in the "Notes" field? "Table of content" based on "Normal Style" behavior!!!! Jamal NUMAN Word 4 07-08-2011 04:12 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:41 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft