Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - If statement with a message

Reply
 
Old 03-05-2009   #1 (permalink)
אמיר עטרי


 
 

If statement with a message


Hello there,

I need help reagarding building a vb script.

The script need to check if Word or Excel is opened (winword.exe & excel.exe)
If they are open to show a message if not to end.

Anyone can help?

Thank you very much
Amir

My System SpecsSystem Spec
Old 03-05-2009   #2 (permalink)
James Whitlow


 
 

Re: If statement with a message

"???? ????" <@discussions.microsoft.com> wrote in message
news:1E733B0A-8032-4B83-BA2B-25CEEB7EC966@xxxxxx
Quote:

>
> Hello there,
>
> I need help reagarding building a vb script.
>
> The script need to check if Word or Excel is opened (winword.exe &
> excel.exe)
> If they are open to show a message if not to end.
>
> Anyone can help?
I think the below will do what you are asking. It does not advise which
one is one, just that at least one instance is.

Set oWMI = GetObject("winmgmts:\root\cimv2")
Set oProc = oWMI.ExecQuery("SELECT * FROM Win32_Process WHERE " _
& "name='WINWORD.EXE' OR name='EXCEL.EXE'")
If oProc.Count > 0 Then
MsgBox "Either Word or Excel (or Both) are open"
End If


My System SpecsSystem Spec
Old 03-05-2009   #3 (permalink)
אמיר עטרי


 
 

Re: If statement with a message


Thank you so much !!

You are great !


"James Whitlow" wrote:
Quote:

> "???? ????" <@discussions.microsoft.com> wrote in message
> news:1E733B0A-8032-4B83-BA2B-25CEEB7EC966@xxxxxx
Quote:

> >
> > Hello there,
> >
> > I need help reagarding building a vb script.
> >
> > The script need to check if Word or Excel is opened (winword.exe &
> > excel.exe)
> > If they are open to show a message if not to end.
> >
> > Anyone can help?
>
> I think the below will do what you are asking. It does not advise which
> one is one, just that at least one instance is.
>
> Set oWMI = GetObject("winmgmts:\root\cimv2")
> Set oProc = oWMI.ExecQuery("SELECT * FROM Win32_Process WHERE " _
> & "name='WINWORD.EXE' OR name='EXCEL.EXE'")
> If oProc.Count > 0 Then
> MsgBox "Either Word or Excel (or Both) are open"
> End If
>
>
>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
How to pass exceptions message outside the trap statement PowerShell
Help with SQL statement VB Script
goal Statement Vista mail
just a statement Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46