Permanently Remove Smart Tags in a Word Document using aspose.words Version 14.3.0.0

Hi,

It seems like document.removeSmartTags method does not permanently Removes all SmartTag in word 2003 document.

How to Permanently Remove Smart Tags in a Word Document using aspose.words ?

In fact i need to do the same like “stop recognising Smart Tags” in Office Word 2003. i thing in this way, SmartTags will be permanently removed. is it possible to achieve that task using aspose.word?

thanks in advance

Hi Stephane,

Thanks for your inquiry. CompositeNode.RemoveSmartTags removes all SmartTag descendant nodes of the current node. This method does not remove the content of the smart tags.

Could you please attach your input and expected output Word document here for testing? I will investigate the issue on my side and provide you more information.

Hi,

thanks for your quick reaction.

I have attached the SmartTagsWord2003Document.doc file

After running the vb.net code :

Dim fileName As String = myDir & "SmartTagsWord2003Document.doc"
Dim Doc As New Document(fileName)
Doc.RemoveSmartTags()
Doc.Save(fileName)

Only Smart Tag On 23 juin 2011,

<st1:personname productid="LA PR￉SIDENCE DE" w:st="on">**LA PRÉSIDENCE DE,** and</st1:personname>
<st1:givenname w:st="on" style="font-weight: bold;">Adrian</st1:givenname>
<st1:sn w:st="on">**Wilson** are removed. All the other Smart Tags remains in the </st1:sn>

SmartTagsWord2003Document.doc document.

What I expect after executing the above vb.net code is that all smart tags in the SmartTagsWord2003Document.doc document. Permanently being removed

I use Office Word 2003, therefore to complete the test in your Development environment you have to Enable Smart tag as mentionned in the http://support.microsoft.com/kb/284927 web site.

thanks in advance

Hi Stephane,

Thanks for sharing the document. Perhaps, you are using an older version of Aspose.Words; as with Aspose.Words v14.3.0, I am unable to reproduce this problem on my side. I would suggest you please upgrade to the latest version of Aspose.Words i.e. v14.3.0 and let us know how it goes on your side. I hope, this will help. I have attached the output Doc file with this post for your kind reference.

Moreover, you can show or hide the purple dotted lines that indicate Smart Tags in Word 2003.

  1. On the Tools menu, click Options, and then click the View tab.
  2. Under Show, select or clear the Smart tags check box.

In Out.doc these purple dots lines are not visible. Please check the attached image for detail. You can also check SmartTag node’s count using following code snippet.

Document doc = new Document(MyDir + "SmartTagsWord2003Document.doc");
Console.WriteLine(doc.GetChildNodes(NodeType.SmartTag, true).Count.ToString());
doc.RemoveSmartTags();
Console.WriteLine(doc.GetChildNodes(NodeType.SmartTag, true).Count.ToString());
doc.Save(MyDir + "Out.doc");
Document doc2 = new Document(MyDir + "Out.doc");
Console.WriteLine(doc2.GetChildNodes(NodeType.SmartTag, true).Count.ToString());

Hi,

Thanks for your quick reply and help

let me share with you the tests i have done.

I used vb.net and Aspose.Words for .NET version 14.3.0.0 (AsposeWordsVersion.png attached file)

Dim Doc1 As New Document(MyDir + "SmartTagsWord2003Document.doc")
Console.WriteLine(Doc1.GetChildNodes(NodeType.SmartTag, True).Count.ToString())
Doc1.RemoveSmartTags()
Console.WriteLine(Doc1.GetChildNodes(NodeType.SmartTag, True).Count.ToString())
Doc1.Save(MyDir + "Out.doc")
Dim Doc2 As New Document(MyDir + "Out.doc")
Console.WriteLine(Doc2.GetChildNodes(NodeType.SmartTag, True).Count.ToString())

As you can see in the result.png attached file, the result is :

23
0
0

It seems like After running the above vb.net code the smart tags have all been removed, and the Out.doc file have no smart tags.

But now, when opening the same Out.doc file with Word 2003, the purple dotted lines that indicate Smart tags in Words 2003, are visible (Out.png attached file).

I don’t want to manually hide the purple dotted lines that indicate presence of Smart tags in Words 2003 by using the word configuration options. These dotted lines should automaticaly disappear after running the above vb.net code even if show the purple dotted line configuration option is enable in word 2003 . If they are always presents, that means Smart tags have not all been removed after executing the above vb.net code.

I have also attached Word2003SmartConfig.png file to show you how are smart tags configured in word.

thanks in advance

Hi Stephane,

Thanks for sharing the detail. Could you please open the Out.doc file shared in my post here in Word 2003 and check either Smart Tags are removed or not?

Please make sure that you have attached the correct document in this forum thread. It would be great if you please share again the input document for which you are getting this issue. I will investigate the issue and provide you more information.

Please download the document from this post and test the same scenario again at your side and share your finding here for our reference.

Hi,

When i open the Out.doc file shared in your post in Word 2003, the result is the same like in my last post as you can see in the Out.png attached file, that is, Smart tags are not all removed.

My actual Computer is Win 7 Pro + SP1 + Word 2003. I have tested the same scenario in another computer With Win XP + Word 2003, and as you can observe the results in the Out1.png attached file, Smart tags are always not all removed.

The input document for which i was getting the last and all my issues is the SmartTagsWord2003Document.doc attached file. this is the same input file that i used in all my previous tests.

Look at the configuration options of smart tags in the Word2003SmartTargsConfig attached file

Thanks in advance

Hi Stephane,

Thanks for sharing the detail. I have tested the scenario again at Windows 7 (64 bit), Word 2003 and have not found the SmartTags in output Document. Please check the attached image. The remove Smart Tag button is disabled. This means that there is no Smart Tags in output Document.

However, If I recheck document by clicking ‘Recheck Document’ button, the Smart Tags appears again. Are you rechecking the document ‘Recheck Document’ button? If yes, please remove the Smart Tags using MS Word and recheck the document using ‘Recheck Document’ button and check the MS Word behavior. Aspose.Words and MS Word behavior is same in this case.

Could you please share your output document here for our reference? I will check that document at my side and share my findings with you.

Hi,

I’m not rechecking the document and the remove Smart Tag button is enable, after testing the scenario. let’s assume that there is an option configure in my word 2003 version which make automatic rechecking the document on opening. Thats’s the only explanation, but it’s remain curious.

Now what i really need is to delete the smart tag permanently, in a way that, even if i recheck the document by clicking ‘Recheck Document button’, smart tags are not found.

You can achieve that in Microsoft Office Word 2003 by following these steps :

  1. Move the insertion point over the text until the Smart Tag Actions button appears.
  2. Click the button, and then point to Stop Recognizing “term”.
  3. Click as Smart Tag to stop recognizing the term.

In Microsoft Office Word 2003, When you stop recognizing a term, you delete the smart tag permanently.
It’s exactly what i want to do with aspose.words. I would like to programmatically and permanently delete Smart Tag in document using aspose.words.
Is it possible achieve that in aspose.words?

Thanks in advance

Hi Stephane,

Thanks for your inquiry.

The Document.RemoveSmartTags method removes all SmartTag nodes from the document. You may check this in Aspose.Words DOM.

Please note that Word 2003 removes the smart tags from your document. However, Word continues to mark new smart tags for any recognizers that are still active (those selected in the Recognizers list on the Smart Tags tab of the AutoCorrect dialog box).

To replace smart tags that you’ve removed, do the following:

  • On the Tools menu, click AutoCorrect Options, click the Smart Tags tab, select check boxes for the recognizers you want to use, and then click Recheck Document to refresh and reapply the smart tags you want to keep in your document.

MS Word 2003 revert back the Smart tags at your side. You can completely turn off all smart tags using MS Word 2003 as follow:

  • On the Tools menu, click AutoCorrect Options, and then click the Smart Tags tab.
  • Clear the Label text with smart tags check box.

Please note that ‘Label text with smart tags’ is MS Word (Application) level setting which is not stored in the document and therefore cannot be controlled by Aspose.Words API. This is completely controlled by the viewer which opens the document.

Hope this answers your query. Please let us know if you have any more queries.