I have a query result being read into an Excel document, but the users want it in word as well. When I try to send it to word, it continues to open in Excel.
Code:
Sub DataGridToWord(output As DataGrid, response As HttpResponse) 'clean up the response.object
response.ContentType = "application/msword"
response.redirect("fileWord.aspx")
'create a string writer
Dim stringWrite As New System.IO.StringWriter()
'create an htmltextwriter which uses the stringwriter
Dim htmlWrite As New System.Web.UI.HtmlTextWriter(stringWrite)
'tell the datagrid to render itself to our htmltextwriter
response.write (output.RenderControl(htmlWrite))
'output the html
Response.Write(stringWrite.ToString)
End Sub