Hi, i have a trial licence at the moment and am just creating a simple bit of code to make sure the DLLs are working, however with the following sample code;
Sub test(ByRef context As HttpContext, strCode As String)
Dim sDocPath As String = context.Server.MapPath(".") & "\templates\word"
Dim docStream As New System.IO.FileStream(IO.Path.Combine(sDocPath, "RD Record Sheet.docx"), IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.ReadWrite)
Dim doc As New Document(docStream)
doc.Range.Replace("{{ADDRESS}}", "Somewhere in the world")
Dim options As OoxmlSaveOptions = New OoxmlSaveOptions()
options.SaveFormat = SaveFormat.Docx
doc.Save(context.Response, "Record - " & strCode & ".docx", ContentDisposition.Attachment, options)
End Sub
When i create the document i get the following message from MS Word;
"Word found unreadable content in XXXXXX.docx do you want to recover the contents etc
What am I doing wrong here ?
Clearly the original DOCX file that i use to open at the beginning of the code is a valid DOCX file, so why can I not export it back to the browser and be able to open it ?
Kind regards
Matt