标签: running-other-programs

如何关闭Word文档的运行实例?(C#)

我可以看到很多非常相似的线程,但似乎没有什么能给我一个应该是非常基本的解决方案.

从我的winforms应用程序中,我需要关闭一个word文档的运行实例(从应用程序本身打开).当我从应用程序中打开word文档时,我会在列表中跟踪它.现在我该如何关闭同一个doc?

这是我尝试过的:

private bool CloseWord(string osPath) //here I pass the fully qualified path of the file
{
    try
    {
        Word.Application app = (Word.Application)Marshal.GetActiveObject("Word.Application");
        if (app == null)
            return true;

        foreach (Word.Document d in app.Documents)
        {
            if (d.FullName.ToLower() == osPath.ToLower())
            {
               d.What? //How to close here?
               return true;
            }
        }
        return true;
    }
    catch
    {
        return true;
    }
}
Run Code Online (Sandbox Code Playgroud)

我得到了很多文档对象的方法,但只有一个.Close()关闭哪个有这样的参数:ref object SaveChanges, ref object OriginalFormat, ref object RouteDocument我不明白.

什么是理想的方式?谢谢..

编辑:

  1. 我无法关闭整个Word应用程序(WinWord),因为用户可能打开了其他word文件.

  2. 我需要终止单词实例(类似的东西Process.Kill())而不提示用户保存或不保存等.

c# office-automation running-other-programs c#-2.0

7
推荐指数
1
解决办法
2万
查看次数

错误6(net :: ERR_FILE_NOT_FOUND):找不到文件c或目录

我正在使用scriptcase php代码生成器,它安装在服务器中,但我通过Web访问它.在有人注销服务器管理员(我使用的用户)之前,这很好.我重新启动服务器并以管理员身份登录,但现在我无法从chrome访问脚本!表明:

Error 6 (net::ERR_FILE_NOT_FOUND): The file or directory could not be found.
Run Code Online (Sandbox Code Playgroud)

我该怎么办?

running-other-programs

4
推荐指数
2
解决办法
16万
查看次数

如何在Matlab上同时运行两个程序?

我的计算机上有一个Matlab许可证.我希望能够在Matlab中同时运行两个程序以节省我的时间,但我不知道我该怎么做.我想知道如何做到这一点.谢谢.

parallel-processing matlab simultaneous running-other-programs

2
推荐指数
1
解决办法
7690
查看次数

Windows是否有自己的'call other .exe'功能(C++)

我知道在C++中有一个函数

system("example.exe");
Run Code Online (Sandbox Code Playgroud)

运行另一个程序,把它需要包含stdlib.h.

因为我已经包含'windows.h',是否system()与Windows中的函数等效?

c++ windows system running-other-programs

0
推荐指数
1
解决办法
1152
查看次数