In an Add-in, I use the following code to format the source code in the active code window:
Dim tdoc As Document = _applicationObject.ActiveDocument
Dim objSel As TextSelection = CType(tdoc.Selection, TextSelection)
objSel.SelectAll()
objSel.SmartFormat()
objSel.Copy()
When I run the above code and then pase the copied code to say a word document then the colrs of the copied source code is not the smae as the same source code in the code window. See the example below:
Source Code in the Code Window:
usingSystem;
namespaceTecnomapas.CTPF.Cadastro
{
[Serializable]
publicclassAtividade
{
#region Atributos
privatedecimal_id;
privateint _numero;
privatestring_nome;
#endregion
--------------------------------------------------------------------------------------------------------
Same Source Code after the executing the code above (i.eobjSel.SmartFormat(); objSel.Copy()). You can namespace 'Tecnomapas.CTPF.Cadastro' should be blue)
using System;
namespace Tecnomapas.CTPF.Cadastro
{
[Serializable]
publicclass Atividade
{
#region Atributos
privatedecimal _id;
privateint _numero;
privatestring _nome;
#endregion
Strangly, if re-run the same code again, the copy contains the correct colors.
What am I doing wrong?
Regards,
Joginder Nahil
www.starprinttools.com