单击按钮打开Word文档 [英] Open word document on button click

查看:102
本文介绍了单击按钮打开Word文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

string ResumeName ="Resume@123.doc";此名称存储在Resume文件夹中的SolutionExplorer中.

现在,我想通过单击按钮打开此简历.请帮助我...

string ResumeName="Resume@123.doc"; This name store in SolutionExplorer inside Resume folder.

Now I want to open this resume by button click. Please help me...

推荐答案

请通过此链接
http://forums.asp.net/t/1444006.aspx
Please go through this link
http://forums.asp.net/t/1444006.aspx


您好,


使用Process类. (在System.Diagnostics中)

Process.Start(ResumeName)

这将启动Word文档的默认处理程序并在其中打开文件.

使用ASP.Net时,您需要:
-授予ASP.NET工作进程帐户(< localmachine> \ ASPNET)与桌面交互的权限,或允许ASP.NET工作进程在SYSTEM帐户中运行.
-启用IIS Admin Service与桌面交互

( http://support.microsoft.com/kb/555134 [
Hello,


Use the Process class. (in System.Diagnostics)

Process.Start(ResumeName)

This will fire up the default handler for word documents and open your file in it.

As you are using ASP.Net you need to:
- Give permission for ASP.NET worker process account (<localmachine>\ASPNET) to interact with desktop or allow ASP.NET worker process to run in SYSTEM account.
- Enable IIS Admin Service to interact with desktop

(http://support.microsoft.com/kb/555134[^])

Valery.


你能不能尝试下面的COde

从添加引用方法"中引用Microsoft.Office.Interop.Word.dll和Office.dll.

HI please can u try Below COde

Refer Microsoft.Office.Interop.Word.dll and Office.dll from Add Reference MEthond

using System.Runtime.InteropServices;
using Word = Microsoft.Office.Interop.Word;





public Word.Document document;

    public static Word.ApplicationClass wd = null;
    public  static int wordWnd              = 0;
    private static string filename          = null;





object fileName = filename;
object newTemplate = false;
object docType = 0;
object readOnly = true;
object isVisible = true;
object missing = System.Reflection.Missing.Value;



document = wd.Documents.Add(ref fileName,ref newTemplate,ref docType,ref isVisible);



document = wd.Documents.Add(ref fileName, ref newTemplate, ref docType, ref isVisible);

wd.Visible = true;
                    wd.Activate();




Vijay




Vijay


这篇关于单击按钮打开Word文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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