Skip to content

Print the Contents of a Web Part in Sharepoint MOSS 2007

by on March 8, 2010

<INPUT type=”button” onclick=”javascript:void(printwebpart(‘WebPartWPQ9’))” value=”Print Web Part 9″ />
<INPUT type=”button” onclick=”javascript:void(printwebpart(‘WebPartWPQ5’))” value=”Print Web Part 5″ />

<script type=”text/javascript”>
function printwebpart(webpartid)
var WebPartElementID = webpartid;


var bolWebPartFound = false;
if (document.getElementById != null)
//Create html to print in new window
var PrintingHTML = ‘\n\n’;
//Take data from Head Tag
if (document.getElementsByTagName != null)
var HeadData= document.getElementsByTagName(“HEAD”);
if (HeadData.length > 0)
PrintingHTML += HeadData[0].innerHTML;
PrintingHTML += ‘\n\n\n’;
var WebPartData = document.getElementById(WebPartElementID);
if (WebPartData != null)
PrintingHTML += WebPartData.innerHTML;
bolWebPartFound = true;
{ bolWebPartFound = false; alert (‘Cannot Find Web Part’); } } PrintingHTML += ‘\n\n’;
//Open new window to print
if (bolWebPartFound)
var PrintingWindow =“”,”PrintWebPart”, “toolbar,width=800,height=600,scrollbars,resizable,menubar”);; PrintingWindow.document.write(PrintingHTML);
// Open Print Window
PrintingWindow.print(); }


Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: