SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 7 of 7
  1. #1
    Junior Member
    Join Date
    Apr 2010
    Posts
    2
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    To check if the Excel is open

    Hi,
    somebody please help me To check if excel is open. If so i need to close it
    Thanks in advance

  2. #2
    Member
    Join Date
    Apr 2009
    Location
    San Diego
    Posts
    413
    Post Thanks / Like
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: To check if the Excel is open

    KillProcessByName ("EXCEL.EXE")

    Function KillProcessByName(sName)
    ' This sub kills all processes specified by sName.
    set objService = getobject("winmgmts:")

    For Each Process in objService.InstancesOf("Win32_process")
    If LCase(process.name) = LCase(sName) Then
    strWBEMPath = "Win32_Process.Handle=" & Process.ProcessID
    ExecuteMethod objService, strWBEMPath, 0
    End If
    Next

    End Function

    Cheers~

  3. #3
    Member
    Join Date
    Oct 2009
    Posts
    64
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: To check if the Excel is open

    Hi, you can use this code.

    Set Word = CreateObject("Word.Application")
    Set Tasks = Word.Tasks
    For Each Task in Tasks
    If Instr(1,Task.Name,"Giveyourexcelfilename")>0 Then
    Task.Close
    Exit For
    End If
    Next
    Word.Quit

  4. #4
    Moderator
    Join Date
    Jan 2007
    Location
    Pittsburgh, PA
    Posts
    2,497
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: To check if the Excel is open

    <font class="small">Code:</font><hr /><pre> 1)
    SystemUtil.CloseProcessByName "excel.exe"


    2)
    On error resume next
    Dim Obj
    Set Obj = GetObject(,"Excel.Application")
    If Not Obj Is Nothing Then
    Obj.Quit
    Set Obj = Nothing
    End If </pre><hr />

  5. #5
    Senior Member
    Join Date
    Mar 2010
    Posts
    118
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: To check if the Excel is open

    you can use this to kill excel application

    <font class="small">Code:</font><hr /><pre>

    CreateObject("WScript.Shell").Run "taskkill /f /im excel.exe"

    </pre><hr />

    To check if excel is running use this function

    <font class="small">Code:</font><hr /><pre>
    msgbox "Excel is Running:" &amp; FindProcess("excel.exe")

    Function FindProcess(ByVal ProcessName)
    FindProcess = False
    Set Shell = CreateObject("WScript.Shell")

    Set ShellResult = Shell.Exec ("TaskList")

    While Not ShellResult.StdOut.AtEndOfStream
    If Instr(ShellResult.StdOut.ReadLine,ProcessName) Then
    FindProcess = False
    Exit Function
    End If
    Wend

    End Function
    </pre><hr />
    Cheers!!!
    Shrikant

  6. #6
    Super Member Jonty's Avatar
    Join Date
    Jan 2007
    Location
    India
    Posts
    1,266
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: To check if the Excel is open

    Do you want to check only if excel is open or a specific workbook or file is open?

    If the purpose is for closing the open instances then you have many possible code noted here.

    If you want to use the existing object, look at Getobject method and continue
    Cheers
    Jonty..
    -- Here to Learn and share ---

  7. #7
    Junior Member
    Join Date
    Apr 2010
    Posts
    2
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: To check if the Excel is open

    I would like to check if the specific workbook is open if open save it as a different name and close the app

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 8.82%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 03:12 PM.

Copyright BetaSoft Inc.