|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Senior Member
Iscritto dal: Jan 2007
Messaggi: 404
|
[AIUTO] Terminare processo di excel in vb6!
Buonsera,
Premendo il pulsante ok mi riempie il file di excel e lo salva fin qua tutto ok ma mi rimane aperto il processo EXCEL.EXE quindi se io voglio ripetere l'operazione mi causa problemi. Il processo termina solo con la chiusura del prog qualcuno sa dirmi come posso chiudere il processo EXCEL.EXE dopo salvato il file?grazie,vi posto il codice :Private Sub cmdOK_Click() Dim appExcel As New Excel.Application Dim cartExcel As Excel.Workbook Dim foglioExcel As Excel.Worksheet Dim sql, sql1 As String Dim num, num1 As Recordset Dim i, k, cont As Integer Dim dirnota1 As String Dim mese8 As Integer mese8 = mese1 If kminiziali.Text = "" Or kmfinali.Text = "" Then MsgBox "Campi obbligatori...", vbCritical, "Attenzione!" Exit Sub ElseIf kminiziali.Text >= kmfinali.Text Then MsgBox "Correggere in Km Iniziali < Km Finali", vbCritical, "Errore!" Exit Sub Else sql = "SELECT dirnota FROM directory" Set num = db.OpenRecordset(sql) dirnota1 = num!dirnota Set cartExcel = Excel.Workbooks.Open(App.Path & "\modelli\notaspese.xls") Set foglioExcel = Excel.Worksheets.Item(1) appExcel.Visible = False foglioExcel.Visible = xlSheetVisible 'apro la connessione e lancio la query per recuperare i dati sql = "SELECT giorno,descrizione,luogo,auto.nome,targa,commessa,km" & _ ",prezzo_c,prezzo_s,pedaggio_s,pedaggio_c,parcheggio_s,parcheggio_c,pranzo_s,pranzo_c" & _ ",cena_s,cena_c,alloggio_s,alloggio_c,telefono_s,telefono_c,spese_s,spese_c " & _ "FROM (utente INNER JOIN auto ON utente.id = auto.idutente) INNER JOIN " & _ "(data INNER JOIN lavoro ON data.id = lavoro.iddata) ON auto.id = lavoro.idauto " & _ "WHERE (lavoro.idutente=" & id & ") and " & _ "(mese = " & mese1 & ") and " & _ "(anno = " & anno1 & ") and " & _ "(idauto= " & idauto & ") order by giorno asc" Set num = db.OpenRecordset(sql) sql1 = "SELECT nome,cognome FROM utente WHERE id=" & id Set num1 = db.OpenRecordset(sql1) i = 12 k = 2 cont = 6 foglioExcel.Cells(2, 6) = num!commessa foglioExcel.Cells(6, 10) = "EURO" foglioExcel.Cells(7, 2) = UCase(num1!cognome) & " " & UCase(num1!nome) foglioExcel.Cells(7, 5) = UCase(genera_mese(mese8)) foglioExcel.Cells(8, 6) = anno1 foglioExcel.Cells(7, 9) = UCase(num!targa) foglioExcel.Cells(7, 12) = UCase(num!nome) foglioExcel.Cells(11, 5) = kminiziali.Text foglioExcel.Cells(46, 5) = kmfinali.Text While num.EOF = False If foglioExcel.Cells(i, 1) = num!Giorno Then If cont < 16 Then If (foglioExcel.Cells(2, 6) <> num!commessa And _ foglioExcel.Cells(4, 6) <> num!commessa And _ foglioExcel.Cells(2, 9) <> num!commessa And _ foglioExcel.Cells(4, 9) <> num!commessa And _ foglioExcel.Cells(2, 12) <> num!commessa And _ foglioExcel.Cells(4, 12) <> num!commessa And _ foglioExcel.Cells(2, 15) <> num!commessa And _ foglioExcel.Cells(4, 15) <> num!commessa) Then If (foglioExcel.Cells(4, 6) <> " " Or _ foglioExcel.Cells(2, 9) <> " " Or _ foglioExcel.Cells(4, 9) <> " " Or _ foglioExcel.Cells(2, 12) <> " " Or _ foglioExcel.Cells(4, 12) <> " " Or _ foglioExcel.Cells(2, 15) <> " " Or _ foglioExcel.Cells(4, 15) <> " ") Then If k = 2 Then k = k + 2 foglioExcel.Cells(k, cont) = num!commessa ElseIf k = 4 Then k = k - 2 cont = cont + 3 foglioExcel.Cells(k, cont) = num!commessa End If End If End If End If foglioExcel.Cells(i, 2) = UCase(num!descrizione) foglioExcel.Cells(i, 3) = UCase(num!luogo) foglioExcel.Cells(i, 4) = num!commessa foglioExcel.Cells(i, 5) = num!km If num!prezzo_c <> 0 Then foglioExcel.Cells(i, 6) = num!prezzo_c If num!prezzo_s <> 0 Then foglioExcel.Cells(i, 7) = num!prezzo_s If num!pedaggio_c <> 0 Then foglioExcel.Cells(i, 8) = num!pedaggio_c If num!pedaggio_s <> 0 Then foglioExcel.Cells(i, 9) = num!pedaggio_s If num!parcheggio_c <> 0 Then foglioExcel.Cells(i, 10) = num!parcheggio_c If num!parcheggio_s <> 0 Then foglioExcel.Cells(i, 11) = num!parcheggio_s If num!pranzo_c <> 0 Then foglioExcel.Cells(i, 12) = num!pranzo_c If num!pranzo_s <> 0 Then foglioExcel.Cells(i, 13) = num!pranzo_s If num!cena_c <> 0 Then foglioExcel.Cells(i, 14) = num!cena_c If num!cena_s <> 0 Then foglioExcel.Cells(i, 15) = num!cena_s If num!alloggio_c <> 0 Then foglioExcel.Cells(i, 16) = num!alloggio_c If num!alloggio_s <> 0 Then foglioExcel.Cells(i, 17) = num!alloggio_s If num!telefono_c <> 0 Then foglioExcel.Cells(i, 18) = num!telefono_c If num!telefono_s <> 0 Then foglioExcel.Cells(i, 19) = num!telefono_s If num!spese_c <> 0 Then foglioExcel.Cells(i, 20) = num!spese_c If num!spese_s <> 0 Then foglioExcel.Cells(i, 21) = num!spese_s num.MoveNext End If i = i + 1 Wend cartExcel.SaveAs dirnota1 & "\Nota Spese " & UCase(num1!cognome) & _ " " & UCase(num1!nome) & " " & UCase(genera_mese(mese8)) & " " & anno1 cartExcel.Close appExcel.Quit Set appExcel = Nothing Unload Me End If End Sub |
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 03:12.










:








