如何使用gridview中的按钮单击事件使用禁用的菜单栏打开Word文件? [英] How can I open word file with disabled menubar using button click event in gridview?

查看:78
本文介绍了如何使用gridview中的按钮单击事件使用禁用的菜单栏打开Word文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用gridview中的按钮单击事件打开带有禁用菜单栏的word文件?

How can I open word file with disabled menubar using button click event in gridview?

protected void btn_show_Click(object sender, EventArgs e)
    {
        
        Button btn = (Button)sender;
        if (btn != null)
        {
            string name = btn.CommandArgument.ToString();
            try
            {
                Microsoft.Office.Interop.Word.Document doc = new Microsoft.Office.Interop.Word.Document();
                Microsoft.Office.Interop.Word.ApplicationClass word = new Microsoft.Office.Interop.Word.ApplicationClass();
                object fileName = (Server.MapPath("~/Uploads/Complaint/" + btn.CommandArgument.ToString() + ""));
                object isVisible = true;
                object missing = System.Reflection.Missing.Value;
                object ConfirmConversions = Type.Missing;
                object ReadOnly = true;
                word.Visible = true;
                //doc = word.Documents.Open(ref fileName, ref ConfirmConversions, ref ReadOnly, ref wordfalse, ref wordfalse, ref AddToRecentFiles, ref PasswordDocument, ref PasswordTemplate, ref Revert, ref WritePasswordDocument, ref WritePasswordTemplate, ref wdOpenFormatAuto, ref XMLTransform, ref wdLeftToRight, ref missing, ref isVisible);
                doc.Activate();
                word.Visible = true;
                word.Activate();
                doc = word.Documents.Open(ref fileName, ref ConfirmConversions, ref ReadOnly, ref isVisible, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible);
                doc = word.ActiveDocument;
                word.Visible = true;
                Response.Flush();
                Response.End();
            }
            catch (COMException e21)
            {
                Response.Write("Error: "+e21.Message);
            }
        }
    }

推荐答案

尝试一下.
同样的讨论在这里...

http://social.msdn.microsoft.com/Forums/zh/worddev/thread/c329f3e5-0e25-44a2-8b07-1182d428de37

Saranya1388
Try this.
The same discussion here...

http://social.msdn.microsoft.com/Forums/en/worddev/thread/c329f3e5-0e25-44a2-8b07-1182d428de37

Saranya1388


这篇关于如何使用gridview中的按钮单击事件使用禁用的菜单栏打开Word文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆