Launch a URL that creates a PDF

I need to launch a url that creates a pdf using lotus script. I can run the code with a button, but the code doesn’t work with lotus script. Below is the code.

Here is the script I was working with:

Dim db As NotesDatabase

Dim session As New notessession

Dim doc As notesdocument

Dim view As NotesView



Set db=session.CurrentDatabase

Set view = db.getview("TMS Scheduled")



Set doc = view.GetFirstDocument



temp1="http://srvform/mshpar/printpdf/open_accidentPrintPDF-pl.cgi?report_case_number(0)="

temp2=doc.AccidentNumber(0)

temp3="&UserID(0)="

temp4=doc.UserName(0)

temp5="&PrtPreview(0)=2"

temp6=temp1+temp2+temp3+temp4+temp5



Print "[" & temp6 & "]"

Here is the code in the button that works also:

temp1:=“http://srvform/mshpar/printpdf/open_accidentPrintPDF-pl.cgi?report_case_number(0)=”;

temp2:=AccidentNumber;

temp3:=“&UserID(0)=”;

temp4:=UserName;

temp5:=“&PrtPreview(0)=2”;

temp6:=temp1+temp2+temp3+temp4+temp5;

@URLOpen(temp6)

Any help would be appreciated. TIA