Click here to Skip to main content
15,894,955 members
Home / Discussions / Windows Forms
   

Windows Forms

 
GeneralRe: report writer Pin
Eddy Vluggen18-Aug-09 23:55
professionalEddy Vluggen18-Aug-09 23:55 
GeneralRe: report writer Pin
εїзεїзεїз18-Aug-09 23:59
εїзεїзεїз18-Aug-09 23:59 
QuestionApplication Running in Recovery Console mode ??? Pin
Member 389641418-Aug-09 17:18
Member 389641418-Aug-09 17:18 
AnswerRe: Application Running in Recovery Console mode ??? Pin
Dave Kreskowiak19-Aug-09 3:45
mveDave Kreskowiak19-Aug-09 3:45 
AnswerRe: Application Running in Recovery Console mode ??? Pin
Eddy Vluggen19-Aug-09 4:41
professionalEddy Vluggen19-Aug-09 4:41 
Questionadd controls inside datagridview windows control Pin
S.Dhanasekaran17-Aug-09 21:58
S.Dhanasekaran17-Aug-09 21:58 
AnswerRe: add controls inside datagridview windows control Pin
Henry Minute20-Aug-09 2:43
Henry Minute20-Aug-09 2:43 
QuestionHow to kill excel.exe for that particular opened excel in vb.net (window application) Pin
Eunice (VB junior)17-Aug-09 17:52
Eunice (VB junior)17-Aug-09 17:52 
Hi,

I try to export datagrid data to one excel spread sheet (i called it ExcelA).
Then, when I want to close ExcelA, I wrote this codes to kill excel.exe.
wExcel.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComObject(wExcel)
System.GC.Collect()
Dim proc As System.Diagnostics.Process
For Each proc In System.Diagnostics.Process.GetProcessesByName("EXCEL")
proc.Kill()
Next
wExcel = Nothing

But then, it killed all the excel that I currently open. (those that are not related to this ExcelA.)

How can i only kill the excel.exe that belonging to this ExcelA ?

Please help. I had tried to search.. but failed to get it.
Thanks in advanced. Appreciate your help. Smile | :)


Here is my codes:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

ds.Clear()

ds.Tables.Add()

If ds.Tables(0).Columns.Count <= 0 Then
For i As Integer = 0 To myTable.Columns.Count - 1
ds.Tables(0).Columns.Add(myTable.Columns(i).ColumnName)
Next
End If

Dim dr1 As DataRow
For k As Integer = 0 To myTable.Rows.Count - 1
dr1 = ds.Tables(0).NewRow
For j As Integer = 0 To myTable.Columns.Count - 1
dr1(j) = dgSearch.Item(k, j)
Next
ds.Tables(0).Rows.Add(dr1)
Next


Dim wExcel As New Excel.ApplicationClass
Dim wBook As Excel.Workbook
Dim wSheet As Excel.Worksheet
wBook = wExcel.Workbooks.Add()
wSheet = wBook.ActiveSheet()

Dim dt As System.Data.DataTable = ds.Tables(0)
Dim dc As System.Data.DataColumn
Dim dr As System.Data.DataRow
Dim colIndex As Integer = 0
Dim rowIndex As Integer = 0

For Each dc In dt.Columns
colIndex = colIndex + 1
wExcel.Cells(1, colIndex) = dc.ColumnName
Next

For Each dr In dt.Rows
rowIndex = rowIndex + 1
colIndex = 0
For Each dc In dt.Columns
colIndex = colIndex + 1
wExcel.Cells(rowIndex + 1, colIndex) = dr(dc.ColumnName)
Next
Next

wSheet.Columns.AutoFit()
Dim strFileName As String = "C:\M2.xls"
Dim blnFileOpen As Boolean = False
Try
Dim fileTemp As System.IO.FileStream = System.IO.File.OpenWrite(strFileName)
fileTemp.Close()
Catch ex As Exception
blnFileOpen = False
End Try

If System.IO.File.Exists(strFileName) Then
System.IO.File.Delete(strFileName)
End If

Try
wBook.SaveAs(strFileName)
wExcel.Workbooks.Open(strFileName)
wExcel.Visible = True
Catch ex As Exception
MsgBox(ex)
Finally
' MsgBox("closing now")
End Try

End Sub

Private Sub Excel_WorkbookBeforeClose(ByVal wBook As Excel.Workbook, ByRef Cancel As Boolean) Handles wExcel.WorkbookBeforeClose
wExcel.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComObject(wExcel)
System.GC.Collect()
Dim proc As System.Diagnostics.Process
For Each proc In System.Diagnostics.Process.GetProcessesByName("EXCEL")
proc.Kill()
Next
wExcel = Nothing

End Sub
AnswerRe: How to kill excel.exe for that particular opened excel in vb.net (window application) Pin
Priyavp16-Nov-09 0:14
Priyavp16-Nov-09 0:14 
QuestionHow to Edit specific columns in datagrid in vb.net (window application)? Pin
Eunice (VB junior)17-Aug-09 17:42
Eunice (VB junior)17-Aug-09 17:42 
AnswerRe: How to Edit specific columns in datagrid in vb.net (window application)? Pin
Henry Minute20-Aug-09 2:46
Henry Minute20-Aug-09 2:46 
Questionchild form minimizing Toplevel Form Pin
sri_009913-Aug-09 17:54
sri_009913-Aug-09 17:54 
AnswerRe: child form minimizing Toplevel Form Pin
Atul Kharecha13-Aug-09 23:12
Atul Kharecha13-Aug-09 23:12 
GeneralRe: child form minimizing Toplevel Form Pin
sri_009914-Aug-09 0:11
sri_009914-Aug-09 0:11 
GeneralRe: child form minimizing Toplevel Form Pin
Atul Kharecha14-Aug-09 0:19
Atul Kharecha14-Aug-09 0:19 
GeneralRe: child form minimizing Toplevel Form Pin
εїзεїзεїз18-Aug-09 21:44
εїзεїзεїз18-Aug-09 21:44 
QuestionHow to keep form always active Pin
sri_009913-Aug-09 17:50
sri_009913-Aug-09 17:50 
GeneralRe: How to keep form always active Pin
mbhosle31-Aug-09 23:23
mbhosle31-Aug-09 23:23 
QuestionAny way to stop menu strip from 'capturing' alt-key? Pin
sri_009913-Aug-09 17:47
sri_009913-Aug-09 17:47 
AnswerRe: Any way to stop menu strip from 'capturing' alt-key? Pin
dan!sh 13-Aug-09 21:31
professional dan!sh 13-Aug-09 21:31 
GeneralRe: Any way to stop menu strip from 'capturing' alt-key? Pin
sri_009913-Aug-09 22:30
sri_009913-Aug-09 22:30 
GeneralRe: Any way to stop menu strip from 'capturing' alt-key? Pin
Eddy Vluggen14-Aug-09 0:22
professionalEddy Vluggen14-Aug-09 0:22 
Questiondrawing and highlighting chess board Pin
benstar11112-Aug-09 22:51
benstar11112-Aug-09 22:51 
AnswerRe: drawing and highlighting chess board Pin
dan!sh 13-Aug-09 20:30
professional dan!sh 13-Aug-09 20:30 
QuestionWindows Shutdown Process Pin
Member 389641410-Aug-09 6:49
Member 389641410-Aug-09 6:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.