Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8840665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:30:51+00:00 2026-06-14T10:30:51+00:00

I’m working on this routine where programatically I need to remove PowerPoint slides that

  • 0

I’m working on this routine where programatically I need to remove PowerPoint slides that are “hidden”. Not knowing much about Open XML I’ve modified a piece of code that originaly deletes a slide where the method takes a slide index as a paramter as describbed in this How to: Delete a slide from a presentation (Open XML SDK) article.

However I’ve learned that the iterating through SlideParts collection will by default sort the slide in order they were last edited and not in the order they appear in the presentation. For that one must iterate through a SlideIdList as suggested in the Iterating of SlideParts with the OpenXml SDK
article.

In my code which include a foreach loop that iterates through the SlideList, I need to get the slide’s Show property in order to get the index of the hidden slide.

Does any one knows how I can get the Show property if I’m using a SlideIdList in my loop? See my comments in code. Thank you! Risho.

public static void DeleteSlide(string presentationFile)
    {
        using (PresentationDocument presentationDocument = PresentationDocument.Open(presentationFile, true))
        {
            // Get the presentation part from the presentation document. 
            PresentationPart presentationPart = presentationDocument.PresentationPart;

            // Get the presentation from the presentation part.
            Presentation presentation = presentationPart.Presentation;

            // Get the list of slide IDs in the presentation.
            SlideIdList slideIdList = presentation.SlideIdList;

            int slideIdx = -1;
            foreach (SlideId _slideId in presentation.SlideIdList)
            {
                slideIdx++;

                string relId = _slideId.RelationshipId.Value;

  >>>>>         // Here is where I need to checkf for Slide.Show.HasValue as
                // as the code suggests but this property belongs to a 
                // presentationDocument.PresentationPart.SlideParts object as in
                // foreach(Slide slide in presentationDocument.PresentationPart.SlideParts.

                if (slide.Slide.Show != null)
                {
                    if (slide.Slide.Show.HasValue != null)
                    {


                        // Pass the presentation to the next CountSlide method
                        // and return the slide count.
                        //return CountSlides(presentationDocument);


                        // Get the slide ID of the specified slide
                        SlideId slideId = slideIdList.ChildElements[slideIdx] as SlideId;

                        // Get the relationship ID of the slide.
                        string slideRelId = slideId.RelationshipId;

                        // Remove the slide from the slide list.
                        slideIdList.RemoveChild(slideId);

                        // Removed code that looks for a custom presentation

                        // Save the modified presentation.
                        presentation.Save();

                        // Get the slide part for the specified slide.
                        SlidePart slidePart = presentationPart.GetPartById(slideRelId) as SlidePart;

                        // Remove the slide part.
                        presentationPart.DeletePart(slidePart);
                        break;
                    }
                }
            }

        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T10:30:53+00:00Added an answer on June 14, 2026 at 10:30 am

    A minute after I’ve posted this I realized that to get the specific slide I needed to do this: SlidePart slidePart = presentationPart.GetPartById(slideRelId) as SlidePart; just before the foreach loop.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I know there's a lot of other questions out there that deal with this
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.