Hoi,
Ik heb al eerder op GOT gezocht en ik kwam een aantal posts tegen met hetzelfde probleem. Ik heb alle advies uit die posts toegepast op mijn code, alleen blijf ik het probleem houden dat op het moment dat ik een excel object sluit (xlApp=nothing) het proces blijft bestaan totdat ik de vb-applicatie sluit.
Kan ik dit proces niet eerder afsluiten of doe ik iets fout?
Ik heb in VB de volgende code:
Het rare is dat de messagebox op het einde gewoon "niets" aangeeft, ofwel xlApp = Nothing = true?! Terwijl Excel proces wel in de lijst blijft staan...
Ik heb al eerder op GOT gezocht en ik kwam een aantal posts tegen met hetzelfde probleem. Ik heb alle advies uit die posts toegepast op mijn code, alleen blijf ik het probleem houden dat op het moment dat ik een excel object sluit (xlApp=nothing) het proces blijft bestaan totdat ik de vb-applicatie sluit.
Kan ik dit proces niet eerder afsluiten of doe ik iets fout?
Ik heb in VB de volgende code:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
| Private Sub Command1_Click()
CommonDialog1.ShowOpen
Dim xlApp As excel.Application
Dim xlBook As excel.Workbook
Dim xlSheet As excel.Worksheet
Screen.MousePointer = vbHourglass
DoEvents
'Set xlApp = New excel.Application
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = False
xlApp.DisplayAlerts = False
xlApp.ScreenUpdating = False
Set xlBook = xlApp.Workbooks.Open(CommonDialog1.FileName)
Set xlSheet = xlBook.ActiveSheet
Dim intCurrentRow As Integer
Dim intLastRow As Integer
Dim strColumnName As String
Dim strColumnTelnr As String
Dim strColumnVKnr As String
strColumnName = "A"
strColumnTelnr = "B"
strColumnVKnr = "C"
intLastRow = ActiveCell.SpecialCells(xlLastCell).Row
StatusBar1.SimpleText = intLastRow & " records in totaal"
Range(strColumnName & "1").Select
intCurrentRow = ActiveCell.Row
Do Until intCurrentRow > intLastRow
StatusBar1.SimpleText = "Bezig met importeren van record " & intCurrentRow & " van " & intLastRow
'Text1.Text = ActiveCell.Value ' Kolom Naam
'hier code om te itereren door kolommen
'Text2.Text = Range(strColumnTelnr & ActiveCell.Row).Value ' Kolom Telnr
'Text3.Text = Range(strColumnVKnr & ActiveCell.Row).Value ' Kolom VKnr
ActiveCell.Offset(1, 0).Activate
intCurrentRow = ActiveCell.Row
Loop
Screen.MousePointer = vbDefault
StatusBar1.SimpleText = "Gereed met het importeren van " & intLastRow & " records"
'MsgBox "Importeren voltooid!"
xlBook.Close
xlApp.Quit
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
If xlApp Is Nothing Then
MsgBox "niets"
End If
End Sub |
Het rare is dat de messagebox op het einde gewoon "niets" aangeeft, ofwel xlApp = Nothing = true?! Terwijl Excel proces wel in de lijst blijft staan...