I'm generating a MS Word document using the OpenXML SDK. I can successfully create a new document and insert hyperlinks. The problem is when opened in MS Word 2010, the link looks like normal text. After examining the file /word/styles.xml I've found it doesn't contain the "Hyperlink" style. How can I programmatically access or create this classic style?
Asked
Active
Viewed 1,372 times
0
-
Have a look at [this answer](http://stackoverflow.com/questions/25056927/unable-to-use-existing-paragraph-styles-in-open-xml/25058393#25058393). They styles in that question / answer are different but the concept is the same. – petelids May 23 '16 at 16:36
-
Thanks for the pointer @petelids. I appreciate it! – Darin Nelson May 24 '16 at 21:22
1 Answers
1
Paragraph res = new Paragraph(
new Hyperlink(new ProofError() { Type = ProofingErrorValues.GrammarStart },
new Run(
new RunProperties(
new RunStyle() { Val = "Hyperlink" }
),
new Text("Text")
)
{ RsidRunProperties = uniqueId},
new ProofError() { Type = ProofingErrorValues.GrammarEnd }
)
{
Id = relationid,
History = new DocumentFormat.OpenXml.OnOffValue(true)
}
)

Pouria golshanrad
- 102
- 1
- 12