检测打开的word文件 [英] Detecting open word file

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

问题描述

大家好。

我有一个用vb6编写的应用程序,其中一个命令按钮运行代码以打开Word 2010文件。我希望能够阻止用户多次单击此按钮,以便Word不会尝试两次打开同一文件(如果它已经打开)。在vb6中以任何
方式执行此操作?

I have an application written in vb6 where a command button runs code to open a Word 2010 file. I want to be able to prevent a user from clicking this button more than once so that Word doesn't try to open the same file twice(If it already is open). Any way to do this in vb6?

谢谢

Tim Christopher

Tim Christopher

推荐答案

您可以在点击它时禁用该按钮,然后您可以验证没有窗口一个标题栏文本,如果没有窗口,你可以实现你的代码来执行单词。

You can disable the button when they click it, then you can verify no window has a certain titlebar text, if no window does, you can then implement your code to execute word.

Public Class Form1
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Button1.Enabled = False
        Dim Processes() As Process = Process.GetProcesses
        Dim IsRunningAlready As Boolean = False
        For Each Process As Process In Processes
            If Process.MainWindowTitle = "The text in the titlebar for MSWORD" = False Then
                IsRunningAlready = True
            End If
        Next
        If IsRunningAlready = False Then
            'Do Something
        End If
    End Sub
End Class


这篇关于检测打开的word文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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