0

コードの何が問題なのか知りたいのですが、テキストフィールドを画像に置き換えようとしています。具体的には、"{no}" を uncheck.jpg に、"{yes}" を check.jpg に置き換えたいと考えています。デバッグすると aDoc.InlineShapes.AddPicture("C:\Users/can.KUMSAATI/Documents/Visual Studio 2012/WebSites/WebSite4/check.jpg", ref missing, ref missing, "{yes }"); 型の不一致。短時間で助けてください。

try
    {
        File.Copy("C:\\Users/can.KUMSAATI/Documents/Visual Studio 2012/WebSites/WebSite4/cover.docx", "C:\\Users/can.KUMSAATI/Documents/Visual Studio 2012/WebSites/WebSite4/temp/" + txtname.Text + " " + txtsur.Text + ".docx", true);
        object missing = Missing.Value;
        Word.Application wordApp = new Word.ApplicationClass();
        Word.Document aDoc = null;
        object filename = "C:\\Users/can.KUMSAATI/Documents/Visual Studio 2012/WebSites/WebSite4/temp/" + txtname.Text + " " + txtsur.Text + ".docx";
        if (File.Exists((string)filename))
        {
            object readOnly = false;
            object isVisible = false;
            wordApp.Visible = false;
            aDoc = wordApp.Documents.Open(ref filename, ref missing,
            ref readOnly, ref missing, ref missing, ref missing,
            ref missing, ref missing, ref missing, ref missing,
            ref missing, ref isVisible, ref missing, ref missing,
            ref missing, ref missing);

            aDoc.Activate();
            this.FindAndReplace(wordApp, "{isim}", txtname.Text);
            this.FindAndReplace(wordApp, "{soyisim}", txtsur.Text);

            if (imgbtnyes.ImageUrl == "~/check.jpg" && imgbtnno.ImageUrl == "~/uncheck.jpg")
            {

                aDoc.InlineShapes.AddPicture("C:\\Users/can.KUMSAATI/Documents/Visual Studio 2012/WebSites/WebSite4/check.jpg", ref missing, ref missing, "{yes}");
                aDoc.InlineShapes.AddPicture("C:\\Users/can.KUMSAATI/Documents/Visual Studio 2012/WebSites/WebSite4/uncheck.jpg", ref missing, ref missing, "{no}");
            }
            else if (imgbtnno.ImageUrl == "~/check.jpg" && imgbtnyes.ImageUrl == "~/uncheck.jpg")
            {
                aDoc.InlineShapes.AddPicture("C:\\Users/can.KUMSAATI/Documents/Visual Studio 2012/WebSites/WebSite4/uncheck.jpg", ref missing, ref missing, "{no}");
                aDoc.InlineShapes.AddPicture("C:\\Users/can.KUMSAATI/Documents/Visual Studio 2012/WebSites/WebSite4/check.jpg", ref missing, ref missing, "{yes}");
            }
            else
            {
                Response.Write("<script LANGUAGE='JavaScript'>alert('Seçiniz');</script>");
            }
            aDoc.Save();
            KillProcess(procname);
            if (aDoc.Saved)
            {
                System.Threading.Thread.Sleep(2000);
                Response.ContentType = "Application/msword";
                Response.AppendHeader("Content-Disposition", "attachment; filename=" + txtname.Text + " " + txtsur.Text + ".docx");
                Response.TransmitFile(Server.MapPath("~/temp/" + txtname.Text + " " + txtsur.Text + ".docx"));
                Response.Flush();
                Response.Close();
                Response.End();
            }
        }
        else
            Response.Write("File does not exist.");
        KillProcess(procname);
    }

    catch (Exception)
    {
        Response.Write("Error in process.");
    }
}
private void FindAndReplace(Word.Application wordApp,
        object findText, object replaceText)
{
    object matchCase = true;
    object matchWholeWord = true;
    object matchWildCards = false;
    object matchSoundsLike = false;
    object matchAllWordForms = false;
    object forward = true;
    object format = false;
    object matchKashida = false;
    object matchDiacritics = false;
    object matchAlefHamza = false;
    object matchControl = false;
    object read_only = false;
    object visible = true;
    object replace = 2;
    object wrap = 1;
    wordApp.Selection.Find.Execute(ref findText, ref matchCase,
        ref matchWholeWord, ref matchWildCards, ref matchSoundsLike,
        ref matchAllWordForms, ref forward, ref wrap, ref format,
        ref replaceText, ref replace, ref matchKashida,
                ref matchDiacritics,
        ref matchAlefHamza, ref matchControl);'
4

0 に答える 0