tags:

views:

1370

answers:

1

I'm trying to create a Word document in vb.net. I can't use the COM Word.Application method due to permission issues on the server. So i've recreated the WORD document in HTML and tried to change the content-type and just output the HTML

It works 'ok'. It outputs the HTML and opens up word with a read-only file with the content in there. However when i hit 'save as' it wants to save as a HTML document even though its opened it in word as file.doc.

Is there a way to fix that so it selects .doc first?

Response.Clear()
Response.AddHeader("content-type", "application/msword")
Response.AddHeader("content-disposition", "inline; filename=" & "file.doc")
Response.Charset = ""
Dim strPath As String = Request.PhysicalApplicationPath & "MainTemp2.html"
Dim fStream As New FileStream(strPath, FileMode.Open, FileAccess.Read)
Dim sReader As New StreamReader(fStream)
Dim strData = sReader.ReadToEnd()
sReader.Close()
Response.Write(strData)
Response.End()

Thank you in advance for your help.

A: 

Word will open a HTML file with the extension .doc happily enough.

Remou