Author Topic: Close all open visio files before creating a new instance  (Read 3510 times)

0 Members and 1 Guest are viewing this topic.

mmtcunningham1

  • Newbie
  • *
  • Posts: 1
Close all open visio files before creating a new instance
« on: May 28, 2008, 10:55:59 PM »
I have code in place that will kill all visio files that are open but I think this is a little extreme and would simply like to check for all open files and prompt the user if they want to close the file.
Here's the code I already have in place:
 Dim myProcesses() As Process = Process.GetProcesses
        Dim myProcess As Process
        For Each myProcess In myProcesses
            If (myProcess.ProcessName.ToLower = "visio") Then
                myProcess.Kill()
            End If
        Next

Any suggestions on how to do this???

Lars-Erik

  • Sr. Member
  • ****
  • Posts: 278
Re: Close all open visio files before creating a new instance
« Reply #1 on: May 29, 2008, 01:57:10 AM »
To be honest, I have no clue what language your code is in :) but couldn't you do something like this?

Code
Dim myProcesses() As Process = Process.GetProcesses
Dim myProcess As Process
For Each myProcess In myProcesses
    If (myProcess.ProcessName.ToLower = "visio") Then
        YesNo = MsgBox("Are you sure you want to stop " & myProcess, vbYesNo, "Stop this process?")
        If YesNo = 6 Then YesNo = True Else YesNo = False
            If YesNo = True Then
                myProcess.Kill()
            Else
            End If
        End If
    End If
Next

- Lars-Erik