我想知道特定路径下的文档有没有打开,要怎么做呢?
时间:2011-02-10
来源:互联网
我想知道特定路径下的文档有没有打开,要怎么做呢?
写了个,不成功,大伙帮忙看看咯
看看特定路径下的文档有没有打开.rar(8.41 KB)
写了个,不成功,大伙帮忙看看咯
附件

2011-2-10 22:41, 下载次数: 2
作者: inadequate 发布时间: 2011-02-10
看看是不是你想要的。
'声明必要的 API:
Private Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Sub ple()
Dim myWd As Object, oDoc As Object
On Error Resume Next
Set myWd = GetObject(, "Word.Application")
Dim hWnd As Long
'如果 Word在运行,则该 API 调用将返回其句柄。
hWnd = FindWindow("OpusApp", 0)
If hWnd <> 0 Then '0 表示没有 Word在运行。
myDocName = ThisWorkbook.Path & "\my.doc"
For Each oDoc In myWd.documents
If UCase(oDoc.FullName) = UCase(myDocName) Then blnFound = True: Exit For
Next
If blnFound = True Then
MsgBox "目标文档已经打开!", vbInformation, "Microsoft Word"
Else
MsgBox "目标文档没有打开!", vbInformation, "Microsoft Word"
End If
End If
End Sub
[ 本帖最后由 wl9643 于 2011-2-10 23:08 编辑 ]
'声明必要的 API:
Private Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Sub ple()
Dim myWd As Object, oDoc As Object
On Error Resume Next
Set myWd = GetObject(, "Word.Application")
Dim hWnd As Long
'如果 Word在运行,则该 API 调用将返回其句柄。
hWnd = FindWindow("OpusApp", 0)
If hWnd <> 0 Then '0 表示没有 Word在运行。
myDocName = ThisWorkbook.Path & "\my.doc"
For Each oDoc In myWd.documents
If UCase(oDoc.FullName) = UCase(myDocName) Then blnFound = True: Exit For
Next
If blnFound = True Then
MsgBox "目标文档已经打开!", vbInformation, "Microsoft Word"
Else
MsgBox "目标文档没有打开!", vbInformation, "Microsoft Word"
End If
End If
End Sub
[ 本帖最后由 wl9643 于 2011-2-10 23:08 编辑 ]
作者: wl9643 发布时间: 2011-02-10
晕,这么复杂呀,还要API。有不要API的吗?
作者: inadequate 发布时间: 2011-02-11
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28