Private Sub Command1_Click()
Dim i As Integer
If Documents.Count >= 1 Then
For i = 1 To Documents.Count
MsgBox Documents(i).Name & " 已经打开!"
Next
Else
MsgBox "No documents are open"
End If
End Sub
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'WORD.EXE'")
For Each objProcess In colProcessList
msgbox “有”
Next
on error resume next
set wdApp=getobject(,"word.application")
if err.number<>0 then
msgbox "没有运行WORD"
else
for each doc in wdApp.documents
s=s & doc.name & chr(10)
next
msgbox "已经打开了" & chr(10) & s