J
jsa1981
I am trying to use ASP.NEt to create a word file and send it to a user.
I have created a button that creates the file. This works great on my
computer, but as soon as I put it on the web server, it gives me the
error:
System.Exception: Cannot create ActiveX component. at
Microsoft.VisualBasic.Interaction.CreateObject(String ProgId, String
ServerName) at TestApp.WordAutomation.Button1_Click(Object sender,
EventArgs e) in D:\main\TestApp\OfficeTests\WordAutomation.aspx.vb:line
44
Here is the code:
Dim filepath As String = Server.MapPath("WordAutomation\") & "wd.doc"
Dim objWD As Word.Application
''''''LINE 44 :
objWD = CreateObject("Word.Application")
objWD.Documents.Add()
objWD.Selection.TypeText("This is some text to test on the Web server.
The time is " & DateTime.Now.ToString)
objWD.ActiveDocument.SaveAs(filename:=filepath)
objWD.Documents.Close()
CType(objWD, Word._Application).Quit()
objWD = Nothing
Response.Clear()
Response.AppendHeader("content-disposition", "attachment;
filename=WordAutomation.doc")
Response.WriteFile(filepath)
Response.End()
I have created a button that creates the file. This works great on my
computer, but as soon as I put it on the web server, it gives me the
error:
System.Exception: Cannot create ActiveX component. at
Microsoft.VisualBasic.Interaction.CreateObject(String ProgId, String
ServerName) at TestApp.WordAutomation.Button1_Click(Object sender,
EventArgs e) in D:\main\TestApp\OfficeTests\WordAutomation.aspx.vb:line
44
Here is the code:
Dim filepath As String = Server.MapPath("WordAutomation\") & "wd.doc"
Dim objWD As Word.Application
''''''LINE 44 :
objWD = CreateObject("Word.Application")
objWD.Documents.Add()
objWD.Selection.TypeText("This is some text to test on the Web server.
The time is " & DateTime.Now.ToString)
objWD.ActiveDocument.SaveAs(filename:=filepath)
objWD.Documents.Close()
CType(objWD, Word._Application).Quit()
objWD = Nothing
Response.Clear()
Response.AppendHeader("content-disposition", "attachment;
filename=WordAutomation.doc")
Response.WriteFile(filepath)
Response.End()