Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am trying to save to msword document but get following error?
{"Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))"}
Does someone now what it means?
Posted
Comments
navin ks 3-May-13 5:44am    
it means what it says..
can u paste the code so that cp experts can solve your error.
Kurac1 3-May-13 5:50am    
private void SetWordDocument()
{
string strFileName =
CleanUp(LabelFirstName.Text + "_" + LabelLastName.Text + "_" + DateTime.Now.ToString("yyyy-MM-dd") +
"." + DropDownListDownloadCv0.SelectedItem.Text);

object fileStream =
new FileStream(Server.MapPath("~/Upload/") +
strFileName,FileMode.Create);


using (var db = new knowitCVdbEntities())
{
var theEmpl = (from p in db.EMPLOYEES
where p.username == strUserName
select p).FirstOrDefault();



if (theEmpl != null)
{

object missing = Missing.Value;
object start1 = 0;


var wordApp = new ApplicationClass();


Microsoft.Office.Interop.Word.Document myDoc = wordApp.Documents.Add(ref missing, ref missing,
ref missing, ref missing);

Range rng = myDoc.Range(ref start1, ref missing);

try
{

const char newLine = (char) 11;

myDoc.SaveAs(ref fileStream,
ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing,
ref missing,
ref missing, ref missing, ref missing);


here i have some textboxes
mydoc.Save();

<pre lang="cs">Response.ContentType = "Application/msword";
Response.AppendHeader("Content-Disposition", "attachment; filename=" + strFileName);
Response.TransmitFile(Server.MapPath("~/Upload/") + strFileName);
Response.End();</pre>
navin ks 3-May-13 5:54am    
:http://www.add-in-express.com/forum/read.php?FID=5&TID=5534
Kurac1 3-May-13 6:04am    
dont get it to work on Microsoft.Office.Interop.Word.Document myDoc = wordApp.Documents.Add(ref missing, ref missing, ref missing, ref missing); here i added ref fileStream also , but then i get same error on that place ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900