Codice PHP:
In un modulo:
Global gCnGestione As ADODB.Connection
Global gRsdvdtotali As ADODB.Recordset
Global gsSQL As String
Nella Form Load:
lst_dvdscelti.Clear
Set gCnGestione = New ADODB.Connection
gCnGestione.Open "FILE NAME=" & App.Path & "\Database.udl"
call caricalista
end sub
Private Sub Caricalista()
lst_tuttidvd.Clear
Set gRsdvdtotali = New ADODB.Recordset
gsSQL = "SELECT * FROM dvdtotali"
gRsdvdtotali.Open gsSQL, gCnGestione
Do While gRsdvdtotali.EOF = False
lst_tuttidvd.AddItem gRsdvdtotali("dvdtotali")
lst_tuttidvd.ItemData(lst_tuttidvd.NewIndex) = gRsdvdtotali("Coddvd")
gRsdvdtotali.MoveNext
Loop
gRsdvdtotali.Close
End Sub
Private Sub selezionadvd()
Set gRsdvdtotali = New ADODB.Recordset
gsSQL = "SELECT * FROM dvdtotali WHERE Coddvd = " & lst_tuttidvd.ItemData(lst_tuttidvd.ListIndex) & ""
gRsdvdtotali.Open gsSQL, gCnGestione
Do While gRsdvdtotali.EOF = False
lst_dvdscelti.AddItem gRsdvdtotali("dvdtotali")
lst_dvdscelti.ItemData(lst_dvdscelti.NewIndex) = gRsdvdtotali("Coddvd")
gRsdvdtotali.MoveNext
Loop
gRsdvdtotali.Close
End Sub
ok cosi vado bene poi inserisco tutto nel modello excel:
Private Sub Stampadvd()
Dim dvd As String
Dim dvdn As String
Dim stit As String
Dim count As Integer
Dim excellapp As New Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim risp As Integer
DoEvents
frmSplash_Stampaincorso.Visible = True
FRM_gdvd.Enabled = False
risp = MsgBox("Vuoi stampare il documento?", 1, "Stampa dvd")
If risp = 1 Then
Set gRsdvdtotali = New ADODB.Recordset
gRsdvdtotali.Open gsSQL, gCnGestione
For i = 0 To lst_dvdscelti.ListCount - 1
excellapp.Workbooks.Open App.Path & "\Data\modello.xls"
excellapp.Worksheets(1).Select
dvd = lst_dvdscelti.List(i)
gsSQL = "SELECT * FROM dvdtotali WHERE dvdtotali = " & lst_dvdscelti.List(i) & ""
dvd = " & lst_dvdscelti.List(i) & "
excellapp.Cells(4, 6) = lst_dvdscelti.List(i)
stit = lst_dvdscelti.List(i)
Set gRsdvdGenerale = New ADODB.Recordset
gsSQL = "SELECT * FROM " & stit & ""
gRsdvdGenerale.Open gsSQL, gCnGestione
count = 12
Do While gRsdvdGenerale.EOF = False
stit = gRsdvdGenerale("dvd")
excellapp.Cells(count, 4) = stit
count = count + 1
gRsdvdGenerale.MoveNext
Loop
gRsdvdGenerale.Close
excellapp.Cells(12, 3) = dvdn
excellapp.Worksheets(1).PrintOut
excellapp.ActiveWorkbook.Close False
excellapp.Workbooks.Close
stit = ""
Set xlSheet = Nothing
Set xlBook = Nothing
Set excellapp = Nothing
Next i
gRsdvdtotali.Close
Else
Call Impostazioniiniziali
End If
If Err Then
MsgBox ("Il file " & stit & " non è stato trovato.")
End If
DoEvents
FRM_gdvd.Enabled = True
frmSplash_Stampaincorso.Visible = False
FRM_gdvd.SetFocus
dvd = ""
dvdn = ""
stit = ""
excellapp.Quit
Set excellapp = Nothing
Call Impostazioniiniziali
End Sub