none
TaskPane Word App - associating data with images or shapes RRS feed

  • Question

  • I have made simple task pane app for Word which allows user to select shape and then attach some properties to it. I am using getSelectedDataAsync method with "ooxml" format and then detect if there is shape in there by processing xml. I am stuck with a problem - there is no way for me to detect if shape was deleted from the app.

         I tried to create binding using addFromSelection method of Bindings object but when shape or image selected this fails with error code 3000.

         As alternative option I was thinking to add "Update from document" button which would just traverse whole document and check if items are still there but getFileAsync method does not allow me to get OOXML of the document, only Compressed or Text.

        Are there any other options I can try?

    Friday, October 24, 2014 4:57 PM

All replies

  • Hi Asterixer,

    It's better that you could provide the related code to me.

    To detect if the shape or image is deleted or not, you could try to bind Office.EventType.BindingSelectionChanged event, after that if you delete the shape or image, it will occurs.

    # EventType enumeration

    http://msdn.microsoft.com/en-us/library/office/fp161159(v=office.1501401).aspx

    To add event binding to the image and shape, please click it and press Ctrl+A to select the all range.

    Best Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, October 27, 2014 6:34 AM
    Moderator
  • If i understand correctly you suggest to ask user to select whole document and then create binding on the whole document? I guess this might work. Is there a way to select whole document automatically? I will try this and post results later.
    Monday, October 27, 2014 1:48 PM
  • I have tried this solution:
    Ask user to select whole document
    Create binding on the whole document using addFromSelectionAsync
    Use getSelectedDataAsync to retrieve ooxml for current selection assign additional data for the rectangles in ooxml(extract id from ooxml and create map from id->properties)
    Additional "Update" button button performs Office.select on the whole document and then  getSelectedDataAsync used to get ooxml and remove properties for rectangles which were deleted

     This is working scenario. Unfortunately it has to rely on user selecting whole document as a first step. Also I did not know that creating binding on selection means wrapping it inside RichTextControl, display of its border can be confusing for the users.  Is there a way to somehow avoid these issues?

     
    Wednesday, October 29, 2014 9:19 PM
  • Hi Asterixer,

    >> I did not know that creating binding on selection means wrapping it inside RichTextControl, display of its border can be confusing for the users.

    I don’t understand clearly. Could you give me detailed explanation?

    Best Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, October 31, 2014 8:08 AM
    Moderator
  • On attached screenshot you can see what I mean. I have created binding on the "Hello" word by selecting it and then using Bindings.addFromSelectionAsync method and then when cursor is inside "Hello" I always see this border around it. Same border is displayed if I insert Rich text control from the "Developer" tab.  


    Tuesday, November 4, 2014 11:04 AM
  • Hi Asterixer,

    This is the default action that used to know which part has binding.

    You may submit the user voice https://officespdev.uservoice.com/forums/224641-general, after you submit it, please post the link here which will benefit others who has similar issue.  

    Best Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, November 5, 2014 3:46 AM
    Moderator