| UseOfficeKillProcesses Method | 
            Terminates process by its name
            
Namespace: SautinSoftAssembly: UseOffice (in UseOffice.dll) Version: 2025.10.22
 Syntax
Syntaxpublic void KillProcesses(
	string _procName
)
Public Sub KillProcesses ( 
	_procName As String
)
Parameters
- _procName  String
- Process name as string
 Remarks
RemarksBeware: this function kill all processes with specified name.
If the MS Word, Excel or PowerPoint processes are still in memory you can use this method to terminate them.
 Example
ExampleASP.Net - How to convert Word Excel PowerPoint files to PDF files in C#
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Drawing;
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            convDir.DataSource = Enum.GetNames(typeof(SautinSoft.UseOffice.eDirection));
            convDir.DataBind();
        }
        resultMessage.Text = "";
        fileMessage.Text = "";
    }
    protected void convDir_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (uploadedDocument.PostedFile.FileName.Length == 0)
        {
            resultMessage.Text = "Please select an input document at first!";
            return;
        }
    }
    protected void convert_Click(object sender, EventArgs e)
    {
        if (uploadedDocument.PostedFile.FileName.Length == 0)
        {
            resultMessage.Text = "Please select an input document at first!";
            return;
        }
        
        
        string workDirectory = @"/converted/";
        string workPath = Server.MapPath(".") + workDirectory;
        Directory.CreateDirectory(workPath);
        string[] allFiles = Directory.GetFiles(workPath, "*.*");
        foreach (string file in allFiles)
            File.Delete(file);
        
        
        string fileName = String.Format("{0: h-m-s-f}", DateTime.Now);
        string tempFilePath = Path.Combine(workPath, fileName + Path.GetExtension(uploadedDocument.PostedFile.FileName));
        File.WriteAllBytes(tempFilePath, uploadedDocument.FileBytes);
        resultMessage.Text = "Converting ...";
        
        
        string ext = ".rtf";
        
        int pos = convDir.Text.LastIndexOf('_');
        pos++;
        ext = (convDir.Text.Substring(pos, convDir.Text.Length - pos)).ToLower();
        if (ext.CompareTo("text") == 0)
        {
            ext = "txt";
        }
        ext = "." + ext;
        
        string resultPath = Path.Combine(workPath, Path.ChangeExtension(uploadedDocument.FileName, ext));
        
        SautinSoft.UseOffice u = new SautinSoft.UseOffice();
        
        if (convDir.Text == "DOC_to_RTF" || convDir.Text == "DOCX_to_RTF" || convDir.Text == "DOC_to_HTML" || convDir.Text == "DOCX_to_HTML" || convDir.Text == "DOC_to_Text" || convDir.Text == "HTML_to_DOC" || convDir.Text == "HTML_to_RTF" || convDir.Text == "HTML_to_Text" || convDir.Text == "RTF_to_Text" || convDir.Text == "RTF_to_HTML" || convDir.Text == "RTF_to_DOC" || convDir.Text == "DOC_to_PDF" || convDir.Text == "DOCX_to_PDF" || convDir.Text == "RTF_to_PDF")
        {
            u.InitWord();
        }
        
        if (convDir.Text == "XLS_to_HTML" || convDir.Text == "XLS_to_XML" || convDir.Text == "XLS_to_CSV" || convDir.Text == "XLS_to_Text")
        {
            u.InitExcel();
        }
        
        if (convDir.Text == "XLS_to_RTF" || convDir.Text == "XLS_to_PDF" || convDir.Text == "XLSX_to_RTF" || convDir.Text == "XLSX_to_PDF")
        {
            u.InitWord();
            u.InitExcel();
        }
        
        if (convDir.Text == "PPT_to_PDF" || convDir.Text == "PPT_to_HTML" || convDir.Text == "PPT_to_RTF" || convDir.Text == "PPTX_to_PDF")
        {
            u.InitPowerPoint();
        }
        SautinSoft.UseOffice.eDirection convDirection = (SautinSoft.UseOffice.eDirection)Enum.Parse(typeof(SautinSoft.UseOffice.eDirection), convDir.SelectedValue);
        if (File.Exists(resultPath))
        {
            File.Delete(resultPath);
        }
        
        int result = u.ConvertFile(tempFilePath, resultPath, convDirection);        
        switch (result)
        {
                
            case 0: resultMessage.Text = "Converting successfully!";
                string href = Request.UrlReferrer.AbsoluteUri;
                href = href.Remove(href.LastIndexOf("/"));                
                href+= workDirectory + Path.GetFileName(resultPath);
                fileMessage.NavigateUrl = href;
                fileMessage.Target = "_blank";
                fileMessage.Text = Path.GetFileName(resultPath);
                break;
            case 1: resultMessage.Text = "Can't open input file."; break;
            case 2: resultMessage.Text = "Can't create output file."; break;
            case 3: resultMessage.Text = "Converting error!"; break;
            default: break;
        }
        
        
        
        u.CloseOffice();
        
        File.Delete(tempFilePath);
    }    
}ASP.Net - How to convert Word Excel PowerPoint files to PDF files in VB.Net
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.IO
Imports System.Drawing
Partial Public Class _Default
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        If Not IsPostBack Then
            convDir.DataSource = System.Enum.GetNames(GetType(SautinSoft.UseOffice.eDirection))
            convDir.DataBind()
        End If
        resultMessage.Text = ""
        fileMessage.Text = ""
    End Sub
    Protected Sub convDir_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
        If uploadedDocument.PostedFile.FileName.Length = 0 Then
            resultMessage.Text = "Please select an input document at first!"
            Return
        End If
    End Sub
    Protected Sub convert_Click(ByVal sender As Object, ByVal e As EventArgs)
        If uploadedDocument.PostedFile.FileName.Length = 0 Then
            resultMessage.Text = "Please select an input document at first!"
            Return
        End If
        
        
        Dim workDirectory As String = "/converted/"
        Dim workPath As String = Server.MapPath(".") & workDirectory
        Directory.CreateDirectory(workPath)
        Dim allFiles() As String = Directory.GetFiles(workPath, "*.*")
        For Each file As String In allFiles
            System.IO.File.Delete(file)
        Next file
        
        
        Dim fileName As String = String.Format("{0: h-m-s-f}", DateTime.Now)
        Dim tempFilePath As String = Path.Combine(workPath, fileName & Path.GetExtension(uploadedDocument.PostedFile.FileName))
        File.WriteAllBytes(tempFilePath, uploadedDocument.FileBytes)
        resultMessage.Text = "Converting ..."
        
        
        Dim ext As String = ".rtf"
        
        Dim pos As Integer = convDir.Text.LastIndexOf("_"c)
        pos += 1
        ext = (convDir.Text.Substring(pos, convDir.Text.Length - pos)).ToLower()
        If ext.CompareTo("text") = 0 Then
            ext = "txt"
        End If
        ext = "." & ext
        
        Dim resultPath As String = Path.Combine(workPath, Path.ChangeExtension(uploadedDocument.FileName, ext))
        
        Dim u As New SautinSoft.UseOffice()
        
        If convDir.Text = "DOC_to_RTF" OrElse convDir.Text = "DOCX_to_RTF" OrElse convDir.Text = "DOC_to_HTML" OrElse convDir.Text = "DOCX_to_HTML" OrElse convDir.Text = "DOC_to_Text" OrElse convDir.Text = "HTML_to_DOC" OrElse convDir.Text = "HTML_to_RTF" OrElse convDir.Text = "HTML_to_Text" OrElse convDir.Text = "RTF_to_Text" OrElse convDir.Text = "RTF_to_HTML" OrElse convDir.Text = "RTF_to_DOC" OrElse convDir.Text = "DOC_to_PDF" OrElse convDir.Text = "DOCX_to_PDF" OrElse convDir.Text = "RTF_to_PDF" Then
            u.InitWord()
        End If
        
        If convDir.Text = "XLS_to_HTML" OrElse convDir.Text = "XLS_to_XML" OrElse convDir.Text = "XLS_to_CSV" OrElse convDir.Text = "XLS_to_Text" Then
            u.InitExcel()
        End If
        
        If convDir.Text = "XLS_to_RTF" OrElse convDir.Text = "XLS_to_PDF" OrElse convDir.Text = "XLSX_to_RTF" OrElse convDir.Text = "XLSX_to_PDF" Then
            u.InitWord()
            u.InitExcel()
        End If
        
        If convDir.Text = "PPT_to_PDF" OrElse convDir.Text = "PPT_to_HTML" OrElse convDir.Text = "PPT_to_RTF" OrElse convDir.Text = "PPTX_to_PDF" Then
            u.InitPowerPoint()
        End If
        Dim convDirection As SautinSoft.UseOffice.eDirection = CType(System.Enum.Parse(GetType(SautinSoft.UseOffice.eDirection), convDir.SelectedValue), SautinSoft.UseOffice.eDirection)
        If File.Exists(resultPath) Then
            File.Delete(resultPath)
        End If
        
        Dim result As Integer = u.ConvertFile(tempFilePath, resultPath, convDirection)
        Select Case result
                
            Case 0
                resultMessage.Text = "Converting successfully!"
                Dim href As String = Request.UrlReferrer.AbsoluteUri
                href = href.Remove(href.LastIndexOf("/"))
                href &= workDirectory & Path.GetFileName(resultPath)
                fileMessage.NavigateUrl = href
                fileMessage.Target = "_blank"
                fileMessage.Text = Path.GetFileName(resultPath)
            Case 1
                resultMessage.Text = "Can't open input file."
            Case 2
                resultMessage.Text = "Can't create output file."
            Case 3
                resultMessage.Text = "Converting error!"
            Case Else
        End Select
        
        
        
        u.CloseOffice()
        
        File.Delete(tempFilePath)
    End Sub
End Class See Also
See Also