Print Problem on Web

Hi,

I have a strange problem. I have a web application and i can print a document attachment from a view. the code is :

Dim tDocuments() As notesDocument

Dim nNbDoc As Integer

Dim sNomVue As String

Dim d As Variant

Dim docid As String

Dim session As New notessession

Dim db As NotesDatabase

Dim tempdoc As NotesDocument



'on va recupérer l'id du document et le nom de la vue

Set tempdoc = session.DocumentContext





sNomVue= getURLParameter(tempdoc.query_string_decoded(0),"view") 



docid="view"



unid=Instr(tempdoc.query_string_decoded(0),"listedoc=")

unid=Mid(tempdoc.query_string_decoded(0),unid+9,32)





'on récupère le nom du fichier attaché

Set db=session.CurrentDatabase

Set doc=db.GetDocumentbyunid(unid) 

Call doc.ReplaceItemValue("StatutImpression", "Envoyé")

Call doc.save(True,True)

Set rtitem = doc.GetFirstItem( "Body" )

Forall att In rtitem.EmbeddedObjects

	If att.Type = EMBED_ATTACHMENT Then

		nom_fichier=att.Source

	End If

End Forall



Dim odoc As notesdocument

Dim sScriptJavascript As String

Dim sIdDoc As String

Dim aaa As String









aaa="http://dominodvt/intranet/drh/abcv/pomonaabcvcand.nsf/ViewAFaireCourriersAEnvoyer/"+unid+"/$file/"+nom_fichier



	

sScriptJavascript = "<script language =""javascript"" > "+_

" window.top.FrameImpression.location.href = '"+aaa+"'; "+_

" window.top.FrameImpression.focus() ; "+_

" window.top.FrameImpression.print(); " +_

" self.close(); " +_

" </script> "

Print sScriptJavascript

When we open the application and print an attachment, this code print a blank page on the first time we print.

But, if we don’t close the application and then we print again this code work very fine.

I don’t know how to resolve it. If you have an idea please help me.

Thanks