PDA

View Full Version : Solved: check for Word running



Jofx
06-01-2005, 12:50 PM
Is it a way (vba or any shell command) to check if a Word session is running ?

Note: the word session could be initiated by user himself, not by a vba routine like getobject or createobject

BlueCactus
06-01-2005, 01:04 PM
Probably, but I can't look into it right now. If not VBA, then I'm sure AppleScript can do it. (You can make AppleScript calls from VBA.)

Jofx
06-01-2005, 01:10 PM
OK, Thanks

BlueCactus
06-01-2005, 11:18 PM
OK, I think this will work for you. Very simple, and there are probably more elegant ways of doing this, but I'm no master of AppleScript...

' The AppleScript reads:
'
' tell application "Finder"
' return processes
' end tell
'
' Note that double-double quotes are used to insert a single double quote into
' the text string ;-)

Sub Test()
Dim scrCode As String, scrResult As String

scrCode = "tell application ""Finder""" & Chr(13) & "return processes" _
& Chr(13) & "end tell"
scrResult = MacScript(scrCode)

If InStr(scrResult, "Microsoft Word") Then
MsgBox "Word is running"
Else
MsgBox "Word is not running"
End If
End Sub

Jofx
06-02-2005, 12:12 AM
Brilliant !!

It works perfectly
thanks a lot, Bluecactus

:friends:

Jofx
06-03-2005, 01:44 PM
I'd like now save and close a workbook from another workbook. I first used "WB.close true" but as it works well on Windows, it doesn't on MAC.
So applescript ?

BlueCactus
06-03-2005, 04:53 PM
I'd like now save and close a workbook from another workbook. I first used "WB.close true" but as it works well on Windows, it doesn't on MAC.
So applescript ?
Works fine for me (Excel X). Does Excel tell you anything when you try to run that code?

Jofx
06-04-2005, 03:22 AM
That's ok now, Bluecactus, I was just annoyed by some authorization concern on Mac.
The folder I wanted to save WB in wasn't allowed to write. Sorry and thanks for your answer.
Jofx

BlueCactus
06-04-2005, 07:36 PM
No problem. Catches everyone out sooner or later. If you're on OS X, typically the only folder you can write to in other users' accounts is User/Public/Drop Box . Problem is, you can't read from that folder.

So you either get access privileges for where you want to store the file, or you create a new folder outside of that User's folder.