codice:
<!-- #include file="Connessioni.asp" -->
<%
'on error resume next
dim codiceanagrafico, codcli, ti(20),nome, cognome, codicefiscale, domicilio, cap,citta,provincia,email,luogonascita,datanascita, provincianascita,dataloc, nominativo, dataodierna
dim telefono, tipodocumento, numerodocumento, luogorilascio,datarilascio, dataiscrizione,note, oggetti(3), j, formname, ThisProgram,ragionesociale,label(10),ReadAllTextFile, NewTextfile
codiceanagrafico=request.QueryString("codiceanagrafico")
dataodierna=fmtDate(now)
SQL="select * from Clienti where CODCLI = " & codiceanagrafico
RS1.Open SQL, conn, 3, 3
if not RS1.EOF then
cognome=ucase(RS1("COGNOME"))
nome=ucase(RS1("NOME"))
nominativo=cognome&" "&nome
codicefiscale=ucase(RS1("CODICEFISCALE"))
domicilio=ucase(RS1("DOMICILIO"))
cap=RS1("CAP")
citta=ucase(RS1("CITTA"))
provincia=ucase(RS1("PROVINCIA"))
email=RS1("email")
luogonascita=trim(ucase(RS1("LUOGONASCITA")))
datanascita=fmtDate(RS1("DATANASCITA"))
provincianascita=ucase(RS1("PROVINCIANASCITA"))
telefono=RS1("TELEFONO")
tipodocumento=ucase(RS1("TIPODOCUMENTO"))
numerodocumento=RS1("NUMERODOCUMENTO")
datarilascio=RS1("DATARILASCIO")
luogorilascio=ucase(RS1("LUOGORILASCIO"))
note=ucase(RS1("NOTECLIENTE"))
else
Session("LASTMSG")="CODICE ANGRAFICO CLIENTE INESISTENTE..."
response.Redirect("errore.asp")
response.end()
end if
RS1.Close
SQL="select * from Configurazione where pk=1"
RS.Open SQL, conn, 3, 3
if not RS.EOF then
label(1)= trim(RS("ragionesociale"))
label(2)= trim(RS("indirizzo"))
label(3)= RS("cap") & " " & trim(RS("citta")) & " (" & RS("provincia") & ")"
label(4)= RS("partitaiva")
label(5)= RS("telefono")
label(6)= RS("email")
dataloc=trim(RS("citta")) & ", " &fmtDate(now)
end if
RS.Close
%>
<html>
<head>
<meta http-equiv="Content-Type" content="application/vnd.ms-word" />
<title>Mandato di vendita Word</title>
</head>
<body>
<%
Dim fileName, filePath, contentType, objStream
Root = Server.MapPath(".")
Folder = "public"
filename = Server.MapPath( "Public/MandatoVendita"& codiceanagrafico & ".doc")
filePath = Server.MapPath( "MandatoVendita.doc" )
ApriFileWord filePath, filename
'response.write "filename=" & filename
'response.write "<br>file template=" & filePath
Response.Flush() ' Invio dell'output bufferizzato
Response.End() ' Chiusura del documento
'Response.Write "<META HTTP-EQUIV=""REFRESH"" Content=""0;URL=\public\" & oFileName & """>"
%>
<script>
document.close();
</script>
</body>
</html>
<!-- #include file="Disconnessioni.asp" -->
<%
function fmtDate(dt)
if isDate(dt) then
fmtDate=right("00"&day(dt),2)&"/"&right("00"&month(dt),2)&"/"&right("0000"&year(dt),4)
else
fmtDate="-"
end if
end function
Function ApriFileWord(strNomeFile, filename)
Dim appWord
Dim docWord
'Set appWord=CreateObject("Word.Application")
On Error Resume Next
Set appWord = Server.CreateObject("word.application")
If Err.number <>0 Then
response.write "Unable to instantiate word. (" & err.Description & ")<br>"
response.write "status=" & Err.Status
response.end()
End If
If (err.number<>0) Then
'fai qualcosa
End If
Set docWord=Server.CreateObject("Word.Document")
If (err.number<>0) Then
appWord.Quit(0)
Set docWord =Nothing
Set appWord=Nothing
'fai qualcosa
response.end()
End If
Set docWord = appWord.Documents.Open(strNomeFile,False)
docWord.SaveAs(filename)
'
docWord.Bookmarks("ragionesocialeditta").Select
'appWord.Selection.InsertAfter("testo da inserire")
appWord.Selection.TypeText label(1)
docWord.Bookmarks("emailditta").Select
appWord.Selection.TypeText label(6)
docWord.Bookmarks("partitaivaditta").Select
appWord.Selection.TypeText label(4)
docWord.Bookmarks("telefonoditta").Select
appWord.Selection.TypeText label(5)
docWord.Bookmarks("nominativo").Select
appWord.Selection.TypeText nominativo
docWord.Bookmarks("nominativo2").Select
appWord.Selection.TypeText nominativo
docWord.Bookmarks("nominativo3").Select
appWord.Selection.TypeText nominativo
docWord.Bookmarks("nominativo4").Select
appWord.Selection.TypeText nominativo
docWord.Bookmarks("codicefiscale").Select
appWord.Selection.TypeText codicefiscale
docWord.Bookmarks("natoa").Select
appWord.Selection.TypeText luogonascita
docWord.Bookmarks("datanascita").Select
appWord.Selection.TypeText datanascita
docWord.Bookmarks("residentea").Select
appWord.Selection.TypeText citta
docWord.Bookmarks("telefono").Select
appWord.Selection.TypeText telefono
docWord.Bookmarks("dataodierna").Select
appWord.Selection.TypeText dataodierna
docWord.Bookmarks("rilasciatoa").Select
appWord.Selection.TypeText luogorilascio
docWord.Bookmarks("tipodoc").Select
appWord.Selection.TypeText tipodocumento
docWord.Bookmarks("numerodoc").Select
appWord.Selection.TypeText numerodocumento
appWord.Visible = True
'docWord.Close(False)
'Set docWord = Nothing
'appWord.Quit(0)
Set docWord = Nothing
End Function
%>
ciao