Visio Guy

Visio Discussions => Programming & Code => Topic started by: mmtcunningham1 on May 29, 2008, 03:55:59 AM

Title: Close all open visio files before creating a new instance
Post by: mmtcunningham1 on May 29, 2008, 03:55:59 AM
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???
Title: Re: Close all open visio files before creating a new instance
Post by: Lars-Erik on May 29, 2008, 06:57:10 AM
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