Delete Specific Tag

C

caten

How can I delete a specific slide tag? I want to delete empty tags. I've
tried this:

Sub Delete_Empty_Tag()
Dim x As Long
Dim oSl As Slide

Set oSl = ActiveWindow.View.Slide
If oSl.Tags.Count > 0 Then
With oSl.Tags
For x = 1 To .Count
If oSl.Tags.Name(x) = "" And oSl.Tags.Value(x) = "" Then
oSl.Tags(x).Delete
End If
Next ' x
End With
End If
End Sub

But I get this error message:
Compile error: Invalid qualifier Tags(x)
(referring to the line " oSl.Tags(x).Delete ")

I'm not sure how the empty tags got there to begin with, but when I
ShowTags, I see tags for which Name="" and Value="", and I want to get rid of
them. I can't seem to target a single, specific Tag for deletion because
there's a Tags (plural) object, but not a Tag (singular) object to be deleted.

Any ideas?
 
J

John Wilson

1. You cant have with osl.tags and THEN If osl.tags..
2. To delete tags use .delete (tagname)

so try

Sub Delete_Empty_Tag()
Dim x As Long
Dim oSl As Slide

Set oSl = ActiveWindow.View.Slide
If oSl.Tags.Count > 0 Then
With oSl.Tags
For x = 1 To .Count
If .Name(x) = "" And .Value(x) = "" Then
..Delete ""
End If
Next ' x
End With
End If
End Sub
 
C

caten

Okay, my code compiles successfully now, but it doesn't delete the tag. When
I ShowTags, the empty tag is still there.

Any other ideas?
 
B

Bill Dilworth

This work for you?

Sub Delete_Empty_Tag()
Dim x As Long
Dim oTag As Tags

Set oTag = ActiveWindow.View.Slide.Tags

With oTag
For x = 1 To .Count
If o.Name(x) = "" And .Value(x) = "" Then .Delete (x)
Next x
End With

End Sub


--
Bill Dilworth
A proud member of the Microsoft PPT MVP Team
Users helping fellow users.
http://billdilworth.mvps.org
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
vestprog2@ Please read the PowerPoint FAQ pages.
yahoo. They answer most of our questions.
com www.pptfaq.com
..
 
C

caten

Nope, Run-time error '424': Object required [referring to: If o.Name(x) = ""
And .Value(x) = "" Then .Delete (x) ]
 
C

caten

This compiles and runs for me but does not delete the tag. When I run
ShowTags, the empty tag is still there.
 
C

caten

No, same result. Thank you for the suggestions. I've just replaced the
slides and copied the content to the new slides. It seems that PowerPoint is
not able to target a tag for deletion if the tag's name or value property (or
both) is blank.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top