none
OBJ characters get inserted in a document having Tracked Changes ON RRS feed

  • Question

  • Hi Everyone,

    I am writing a add-in for Word Online.
    I am using search API. I see that if document contains tracked changes, on calling search API OBJ character gets inserted before and after the search string.

    Steps to reproduce:
    1. Create a document using Word desktop version with tracked change ON.

    2. Add some text delete some text.

    3. Upload document to OneDrive and open it using Word Online

    4. In you add-n code add a simple search operation

    Word.run(function (context) {
    	context.document.body.search("text-to-search", { matchCase: true });
    	return context.sync();
    });

    5. You will see OBJ characters get inserted in the document wherever text-to-search is found.

    Sadly I couldn't upload a screenshot as my account is not verified :(

    Note: This occurs only if Track Changes is "ON" for the document.

    Thanks,
    Abhijeet

    Thursday, September 6, 2018 11:43 AM

Answers

  • Hi Abhijeet,

    Sorry for the late reply.

    I have used the document that you provided and follow the steps in your video but still can't reproduce your problem. 

    Did you install some special characters in your computer?

    At the beginning of the case, i've created a word web add-in project in VSTO, and then deployed it to my word online.

    Here is the code written in my Home.js, and you can copy it to your code for a test:

    (function () {
        "use strict";
    
        // The initialize function must be run each time a new page is loaded.
        Office.initialize = function (reason) {
            $(document).ready(function () {            
                $('#button-text').text("search 'document'");            
                $('#highlight-button').click(hightlightLongestWord);            
            });
        };
        
        function hightlightLongestWord() {
            Word.run(function (context) {            
                var range = context.document.getSelection();            
                var test;                       
                return context.sync()
                    .then(function () {                    
                        test = context.document.body.search("document", { matchCase: true })
                        context.load(test, 'font');
                    })
                    .then(context.sync)
                    .then(function () {
                        test.items[0].font.highlightColor = '#FFFF00'; // Yellow
                        test.items[0].font.bold = true;
                    })
            })
            .catch(errorHandler);
        }     
    
        //$$(Helper function for treating errors, $loc_script_taskpane_home_js_comment34$)$$
        function errorHandler(error) {
            // $$(Always be sure to catch any accumulated errors that bubble up from the Word.run execution., $loc_script_taskpane_home_js_comment35$)$$
            showNotification("Error:", error);
            console.log("Error: " + error);
            if (error instanceof OfficeExtension.Error) {
                console.log("Debug info: " + JSON.stringify(error.debugInfo));
            }
        }  
    })();

    To avoid this kind of problems, try to test it on another computer.

    Hopefully it helps you.

    Best Regards,

    Yuki


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.


    Monday, September 17, 2018 10:11 AM
    Moderator

All replies

  • Hi Abhijeet,

    We are investigating your case now.

    Once we could reproduce your issue, we will get back to you as soon as possible. 

    Thanks for your understanding.

    Best Regards,

    Yuki


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    Friday, September 7, 2018 12:03 PM
    Moderator
  • Thanks Yuki,

    Waiting for your reply

    Best,
    Abhijeet
    Tuesday, September 11, 2018 4:36 AM

  • I could also reproduce the same for fields in Word.

    Steps to reproduce for fields

    In Word desktop
    1. Insert Field : INSERT tab -> Quick Parts -> Fields -> Date (choose any)

    2. Add some text after the field

    3. After the text in the same paragraph add another field

    4. Upload the document to OneDrive and open using Word Online

    4. Execute the following code from add-in

    Word.run(function (context) {
    	context.document.body.search("text-to-search", { matchCase: true });
    	return context.sync();
    })

    5. Close document or refresh to check OBJ(Object Replacement character) character getting inserted in document

    Also you can check the OOXML for the document to confirm

    Thanks
    Abhijeet

    Wednesday, September 12, 2018 6:35 AM
  • Hi Abhijeet,

    Sorry for late response and thank you for your description.

    Unfortunately, following your steps, we did not reproduce the problem.

    You can take a look at how we did it: 

    My version of Office is Office2016(64bit). Also, what version of your Office?

    Could you please take a screenshot or show us the issue? 

    Looking forward to hearing from you.

    Best Regards,

    Yuki


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.


    Wednesday, September 12, 2018 10:08 AM
    Moderator
  • Hi Yuki,

    I have clearly mentioned in "step 3" to  to use Word Online by uploading the document to One drive.

    My account isn't verified cannot attach image.

    I have uploaded screenshot on hightail here https://spaces.hightail.com/receive/SCvooLNwVy

    Thanks
    Abhijeet

    Thursday, September 13, 2018 8:11 AM
  • Hi Abhijeet,

    I test it using word online and can't get the same error as you.

    I upload a document with tracked change ON.

    And there's no OBJ characters get inserted in the document wherever "document" is found.

    Please see the gif below:

    Could you please share your word with us? And check if the problem also occurs on other PC.

    Best Regards,

    Yuki


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    Friday, September 14, 2018 10:39 AM
    Moderator
  • Hi Yuki,

    Here is an attached word document and also a video about the problem.
    I have used the Word Rich Api addin from store just for demo purpose. 

    https://spaces.hightail.com/receive/1NKWmu54jK

    The OBJ(Object replacement character) takes about 5-10 second to appear

    It's reproducible on all browsers Edge, Firefox, Chrome.

    Could you post the code you have wriiten for search, so I can compare to see if I am doing something wrong.

    Thanks,
    Abhijeet


    Friday, September 14, 2018 1:45 PM
  • Hi Abhijeet,

    Sorry for the late reply.

    I have used the document that you provided and follow the steps in your video but still can't reproduce your problem. 

    Did you install some special characters in your computer?

    At the beginning of the case, i've created a word web add-in project in VSTO, and then deployed it to my word online.

    Here is the code written in my Home.js, and you can copy it to your code for a test:

    (function () {
        "use strict";
    
        // The initialize function must be run each time a new page is loaded.
        Office.initialize = function (reason) {
            $(document).ready(function () {            
                $('#button-text').text("search 'document'");            
                $('#highlight-button').click(hightlightLongestWord);            
            });
        };
        
        function hightlightLongestWord() {
            Word.run(function (context) {            
                var range = context.document.getSelection();            
                var test;                       
                return context.sync()
                    .then(function () {                    
                        test = context.document.body.search("document", { matchCase: true })
                        context.load(test, 'font');
                    })
                    .then(context.sync)
                    .then(function () {
                        test.items[0].font.highlightColor = '#FFFF00'; // Yellow
                        test.items[0].font.bold = true;
                    })
            })
            .catch(errorHandler);
        }     
    
        //$$(Helper function for treating errors, $loc_script_taskpane_home_js_comment34$)$$
        function errorHandler(error) {
            // $$(Always be sure to catch any accumulated errors that bubble up from the Word.run execution., $loc_script_taskpane_home_js_comment35$)$$
            showNotification("Error:", error);
            console.log("Error: " + error);
            if (error instanceof OfficeExtension.Error) {
                console.log("Debug info: " + JSON.stringify(error.debugInfo));
            }
        }  
    })();

    To avoid this kind of problems, try to test it on another computer.

    Hopefully it helps you.

    Best Regards,

    Yuki


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.


    Monday, September 17, 2018 10:11 AM
    Moderator
  • Hi Abhijeet,

    Thanks for your asking. Did you resolve your issue ? If the post helps you, you can mark it as answer and close the post.

    Thank you for understanding. If you have any question, or update, please feel free to let us know.

    I wish you a happy life!

    Best Regards,

    Yuki

    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    Wednesday, September 19, 2018 8:38 AM
    Moderator
  • Hi Yuki,

    Sorry for late reply,

    I could resolve the issue for Track Changes

    Changes I made to my code:
    1. Added context.document.untrack()

    2. Called context.load() on search result, though I do not use the property later in code.

    But i could still reproduce this issue for fields.

    Attached a sample document here: https://spaces.hightail.com/receive/OmWqa6iOI9

    Steps to reproduce

    1. Open document containing fields and text between them(Document attached)

    2. Run following code

    3. Refresh document. 

    4. Observe: Field text changes to normal text also OBJ character gets appended before field

    Word.run(function (context) {
    context.document.untrack();
    var res;	
    	return context.sync()
    	.then(function() {
    		res = context.document.body.search("test", { matchCase: true });
    		res.load("items");
    	})	
    	.then(context.sync)
    	.then(function () {
    		res.items[0].select();
    	});
    })

    Thanks,
    Abhijeet


    Thursday, September 20, 2018 8:40 AM