Consulting

Results 1 to 9 of 9

Thread: Solved: check for Word running

  1. #1
    VBAX Regular
    Joined
    May 2005
    Posts
    6
    Location

    Solved: check for Word running

    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

  2. #2
    VBAX Tutor
    Joined
    Mar 2005
    Posts
    268
    Location
    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.)

  3. #3
    VBAX Regular
    Joined
    May 2005
    Posts
    6
    Location
    OK, Thanks

  4. #4
    VBAX Tutor
    Joined
    Mar 2005
    Posts
    268
    Location
    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]

  5. #5
    VBAX Regular
    Joined
    May 2005
    Posts
    6
    Location
    Brilliant !!

    It works perfectly
    thanks a lot, Bluecactus


  6. #6
    VBAX Regular
    Joined
    May 2005
    Posts
    6
    Location
    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 ?

  7. #7
    VBAX Tutor
    Joined
    Mar 2005
    Posts
    268
    Location
    Quote Originally Posted by Jofx
    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?

  8. #8
    VBAX Regular
    Joined
    May 2005
    Posts
    6
    Location
    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

  9. #9
    VBAX Tutor
    Joined
    Mar 2005
    Posts
    268
    Location
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •