none
Determinate ZOrder of shapes compared to other objects behind and/or on top of that shape

    问题

  • Hi

    A powerpoint slide with several placeholders and textboxes in front and behind some of the placeholders. A "Bug" in Office 2010/07 is that if you have for instance a picture placeholder behind a textbox and inserts an image to that placeholder and deletes the image again, the placeholder will be placed on top of the textbox and not behind. 

    This is an issue because I support inserting items to selected placeholders. When I delete the items in the placeholders that was not selected, all of the textboxes that where in front are now in the back.

    I know I can get the shapes' ZOrder but textboxes aren't part of that, right? Any ideas how this can be fixed?

    2012年3月22日 14:56

答案

  • I found a solution. Since I'm supporting inserting images to selected placeholders in the way that I add images to all placeholders until I reach the selected one, and then deletes the one I don't need, I need to change the ZOrder of the placeholders I delete the content of. Or more accurate said; when deleting a picture that was inserted into a placeholder, Office deletes the image and "restores"/creates the placeholder. When adding new objects to a slide they get the highest ZOrder. Office doesn't fix this for placeholders when deleting content.

    In the loop I have for deleting the content of placeholders that are not selected I first store the ZOrderPosition. I then delete the content, gets the last shape inserted (which is now the placeholders Office inserted), and moves it backwards until it has the same ZOrderPosition.

    var count = selectedSlide.Shapes.Count;
    var newPlaceholder = selectedSlide.Shapes[count];

    ...

    var currentZOrder = selectedSlide.Shapes[j].ZOrderPosition;
    if (currentZOrder > imageZOrder)
       {
           // Send the new placeholder backwards
           newPlaceholder.ZOrder(Microsoft.Office.Core.MsoZOrderCmd.msoSendBackward);
        }

    2012年3月27日 8:52

全部回复

  • Hi MartinMyth,

    Thanks for posting in the MSDN Forum.

    Would you please clarify whether you use programmical way to handle your issue? You issue seems an end-user issue. I would recommend you post it in the Answer Forum for better support.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    2012年3月23日 3:41
  • Hi MartinMyth,

    Thanks for posting in the MSDN Forum.

    Would you please clarify whether you use programmical way to handle your issue? You issue seems an end-user issue. I would recommend you post it in the Answer Forum for better support.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Hi Tom, I can see that my question doesn't clearly show you what I'm doing. I'm creating a add-in for word and powerpoint, supporting 07/10, using C#. So this is a programmatic question.

    -Martin

    2012年3月23日 8:26
  • Hi Martin,

    OK, Let's work on it.

    Would you please show me some sinppet for your issue. I think that will help us approach your goal faster.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    2012年3月26日 6:01
  • I found a solution. Since I'm supporting inserting images to selected placeholders in the way that I add images to all placeholders until I reach the selected one, and then deletes the one I don't need, I need to change the ZOrder of the placeholders I delete the content of. Or more accurate said; when deleting a picture that was inserted into a placeholder, Office deletes the image and "restores"/creates the placeholder. When adding new objects to a slide they get the highest ZOrder. Office doesn't fix this for placeholders when deleting content.

    In the loop I have for deleting the content of placeholders that are not selected I first store the ZOrderPosition. I then delete the content, gets the last shape inserted (which is now the placeholders Office inserted), and moves it backwards until it has the same ZOrderPosition.

    var count = selectedSlide.Shapes.Count;
    var newPlaceholder = selectedSlide.Shapes[count];

    ...

    var currentZOrder = selectedSlide.Shapes[j].ZOrderPosition;
    if (currentZOrder > imageZOrder)
       {
           // Send the new placeholder backwards
           newPlaceholder.ZOrder(Microsoft.Office.Core.MsoZOrderCmd.msoSendBackward);
        }

    2012年3月27日 8:52
  • Hi Martin,

    I'm glad to hear you have solved it by yourself. Thanks for sharing your experience here, it's very beneficial for other community members who have similar question to see how you solved your question.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    2012年3月28日 2:15