-1

How can I set the text codification of my open xml document ?

In Office 2003, when I open a document that was build through Open XML, a error appears about codification, like that. How can I set the codification or how can I fix this error ?

I have the Compatibility pack installed, and I can open every .docx file, but this one seems that I need set the codification.

How I create the document

private static void BuildDocument(string fileName, List<string> lista, string tipo)
        {     

            using (WordprocessingDocument w = WordprocessingDocument.Create(fileName, WordprocessingDocumentType.Document))
            {                
                MainDocumentPart mp = w.AddMainDocumentPart();
                DocumentFormat.OpenXml.Wordprocessing.Document d = new DocumentFormat.OpenXml.Wordprocessing.Document();
                Body b = new Body();                
                DocumentFormat.OpenXml.Wordprocessing.Paragraph p = new DocumentFormat.OpenXml.Wordprocessing.Paragraph();
                Run r = new Run();
                for (int i = 0; i < lista.Count; i++)
                {
                    Text t = new Text();
                    t.Text = lista[i];

                    if (t.Text == "          ")
                    {
                        r.Append(new CarriageReturn());
                    }
                    else
                    {                        
                        r.Append(t);
                        r.Append(new CarriageReturn());
                    }
                }

                lista.Clear();
                p.Append(r);
                b.Append(p);
                HeaderPart hp = mp.AddNewPart<HeaderPart>();
                string headerRelationshipID = mp.GetIdOfPart(hp);
                SectionProperties sectPr = new SectionProperties();
                HeaderReference headerReference = new HeaderReference();
                headerReference.Id = headerRelationshipID;
                headerReference.Type = HeaderFooterValues.Default;
                sectPr.Append(headerReference);
                b.Append(sectPr);
                d.Append(b);

                hp.Header.Save();
                mp.Document = d;
                mp.Document.Save();
                w.Close();
            }             
        }
Lucas_Santos
  • 4,638
  • 17
  • 71
  • 118

1 Answers1

1

Open XML is only for Office documents 2007 and older. Office 2003 and under is not compatible with Open XML and that is why you are getting this popup. This is not controllable through Open XML and only Word will give the popup when you open an incompatible document.

amurra
  • 15,221
  • 4
  • 70
  • 87