Force the browser to display the open/save dialog box when user is downloading a file.

This code is useful for PDF's, Word doc's, etc... when the browser automatically opens the document. Inserting the two lines of code below will force the browser to prompt the user with the Open/Save/Cancel dialog box.

Sub Initialize
	Dim session As New notessession
	Dim db As notesdatabase
	Set db = session.currentdatabase
	Dim doc As notesdocument
	Set doc = session.DocumentContext
	'Get parent document and attachment
	Dim pdoc As NotesDocument
	Set pdoc = db.GetDocumentByUNID( doc.ParentDocumentUNID )
	Dim URL As String
	URL = "/"  & doc.dbURL(0) & "/files/" & doc.ur_compname(0) & "~" & doc.ur_title(0) & "/$File/" & pdoc.dr_attachmentname(0) & "?OpenElement"
	'Force the browser to download and pass the file URL
	Print "Content-Type:application/download"
	Print "Content-Disposition:attachment; filename=" & Chr(34) & Cstr(pdoc.dr_attachmentname(0)) & Chr(34)
	Print "[" + URL + "]"
End Sub

Posted by fbrefere001 on Thursday February 20, 2003