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
Printable View
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
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.)
OK, Thanks
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...
[vba]' 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[/vba]
Brilliant !!
It works perfectly
thanks a lot, Bluecactus
:friends:
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?Quote:
Originally Posted by Jofx
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
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.