Hallo to everybody,I have this problem in web appplication.
I have an agent that create an excel file in c:\
when click botton this agent run, search any document and create file “interventi.xls” with some field of document.
If run this agent in notes client work correctly but in web i have this error “Disk i/o is a restricted operation”
i set runtime security level at “allow restricted operations”
Someone can halp me?
Thank’s a lot
This is my agent:
Sub Initialize
On Error Goto errore
Dim s As New NotesSession
Dim db As NotesDatabase
Dim vista As NotesUIView
Dim coll As NotesDocumentCollection
Dim doc As NotesDocument
Dim doc_int As NotesDocument
Set db=s.CurrentDatabase
Set doc= s.DocumentContext
tecnico=doc.tecnico(0)
data_inizio=doc.data_inizio(0)
data_fine=doc.data_fine(0)
'vado a prendere i documenti degli interventi del tecnico scelto
searchformula$ = "select form = ""dett_interventi"" & ordine_tecnico= """ & tecnico & """ & esportato= """ & "No" & """"
Set coll = db.Search(searchformula$,Nothing,0)
'se non trova documento va alla fine dell'agente
If coll.Count=0 Then
Print "Non è stato trovato nessun documento relativo alla persone indicata nel range di date inserito!"
Goto fine
End If
'riga da cui parto a scrivere nel file excel di esportazione che mi creo
x=5
'setto il file excel
'INIZIO MODIFICA MATTEO
'vado nella vista templates e mi prendo il prototipo di documento excell
Dim Vtemp As NotesView
Set Vtemp = db.GetView("templates")
Dim doc_temp As NotesDocument
Dim coll_temp As NotesDocumentCollection
Set coll_temp=Vtemp.GetAllDocumentsByKey("DETT_INTERVENTO")
Set doc_temp = coll_temp.GetFirstDocument
Dim rtm As NotesRichTextItem
Set rtm = doc_temp.GetFirstItem("tmp_intervento")
'Create Excel Object
Set excelApp = CreateObject("Excel.Application")
If excelApp Is Nothing Then
message$ = "Could not create spreadsheet." & Chr$( 10 ) & _
"Make sure Excel is installed on this computer."
Msgbox message$, 16, "Creazione del Foglio di lavoro Excel fallita."
Continue = False
Exit Sub
End If
'setto il nome del file
Dim nomedoc As String
nomedoc = "Interventi" & ".xls"
'setto il percorso
Dim percorso As String
percorso = "c:\" & nomedoc
'Prompt for Excel file location and save.
Set excelWkbks = excelApp.Workbooks
'vtFileName = w.SaveFileDialog(False, "Choose New File", "Microsoft Excel|*.xls", "c:\windows\desktop")
'If Isempty(vtFileName) Then Exit Sub
Set excelNewWkbk = excelWkbks.Add
Call excelNewWkbk.SaveAs(percorso) '(vtFileName(0))
Set excelSheet1 = excelNewWkbk.ActiveSheet
'di tutti i documenti del tecnico, prendo quelli compresi nel range di date
For i=1 To coll.Count
Set doc_int=coll.GetNthDocument(i)
'controllo che la data dell'intervento è compresa tra quelle da esportare
If (doc_int.data(0)>=Cdat(data_inizio)) And (doc_int.data(0)<=Cdat(data_fine)) Then
data_int=doc_int.data(0)
codice_int=doc_int.codice(0)
im_int=doc_int.im(0)
clinete_int=doc_int.cliente(0)
indirizzo_int=doc_int.indirizzo(0)
prov_int=doc_int.prov(0)
int_int=doc_int.interv(0)
apparec_int=doc_int.apparecchiatura(0)
'per ogni documento trovato esporto i dati e inserisco il flag esportato
'*************************************************************************************************************************
'inserisco i dati nelle celle del primo foglio di excel (l'intestazione del preventivo)
excelSheet1.Cells(x, 2).value=Cstr(data_int)
excelSheet1.Cells(x, 3).value=Cstr(codice_int)
excelSheet1.Cells(x, 4).value=Cstr(im_int)
excelSheet1.Cells(x, 5).value=Cstr(clinete_int)
excelSheet1.Cells(x, 6).value=Cstr(indirizzo_int)
excelSheet1.Cells(x, 7).value=Cstr(prov_int)
excelSheet1.Cells(x, 8).value=Cstr(int_int)
excelSheet1.Cells(x, 9).value=Cstr(apparec_int)
Print "scrivo excel"
'*************************************************************************************************************************
End If
x=x+1
'inserisco nel documento esportato il flag nel campo esportato che indica che è stato esportato in excel
doc_int.esportato="Si"
Call doc_int.Save(True,False)
Next i
'non posso chiedere dove salvare xchè è un'agente
'chiedo il percorso di salvataggio del file excel
'vtFileName = w.SaveFileDialog(False, "Choose New File", "Microsoft Excel|*.xls", "c:\windows\desktop")
'lo salvo nella directory c:/interventi
vtFileName = "c:\interventi"
If Isempty(vtFileName) Then Exit Sub
Call excelNewWkbk.SaveAs(percorso) '(vtFileName(0))
'Tidy Up by making title row bold, setting columns to autofit,
'and running sort on all rows, if necessary.
Print "Il programma sta riordinando il foglio di Excel..."
excelSheet1.Range("1:1").Font.Bold = True
excelSheet1.Columns.AutoFit
If iSortBy <> 0 Then
'(Key1, Order1, Key2, Type, Order2, Key3, Order3, Header, _
'OrderCustom, MatchCase, Orientation, SortMethod)
Call excelSheet1.UsedRange.Sort(excelSheet1.Cells(1, iSortBy), , , , _
, , , XLYES)
End If
Print "Il programma sta salvando il foglio di Excel..."
excelNewWkbk.Save
excelNewWkbk.Close
fine:
Print "Procedura Terminata."
Exit Sub
errore:
Print "Errore alla riga n° " & Cstr(Erl()) & " " & Error
Exit Sub
End Sub