Close all open visio files before creating a new instance

Started by mmtcunningham1, May 29, 2008, 03:55:59 AM

Previous topic - Next topic

Nikolay and 1 Guest are viewing this topic.

mmtcunningham1

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

To be honest, I have no clue what language your code is in :) but couldn't you do something like this?

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