Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

printing of dynamic web report 1

Status
Not open for further replies.

rubthegecko

Programmer
Apr 13, 2001
2
CA
gecko1.jpg


Hello everyone..

Here is my dilemma.

ad-hoc reporting

I have a dynamic report that is querying data from oracle and is displaying it on an xml based web page. There are some basic javascripts in the code that allow the user to sort the data after it is displayed.

PROBLEM

How can I get it to print. Here is one solution that I have tried and it works but the boss wants it all in one button.
Code:
<input type='button' value='Send To Word' 

onClick=&quot;fnDoCopyWord();
<script language=&quot;Javascript&quot;>
function fnDoCopyWord(){
     textRange=document.body.createTextRange();
     textRange.moveToElementText(listTable);
     textRange.execCommand(&quot;Copy&quot;);
     window.open(&quot;c:\WordOutput.doc&quot;,&quot;printing&quot;);
     }
</script>

Any help would be appreciated. This wall is especially hard on my forehead..
 
Hello,
If I understood correctly you need to have some text in a web page, then select a portion of it and copy to a MS Word document, then print from MS Word.
This is called (OLE) Automation. If you do this from html page you will be prompted for security hazard.

A possible solution using VBScript is:

<html>
<head>
<script language=&quot;VBScript&quot;>
Sub printTextViaWord(strText)
'Declare and create an MS Word.Application Object
Dim objWord
Set objWord = CreateObject(&quot;Word.Application&quot;)

'Show the Word application
'if next line is commented,
'the application will work in background)
objWord.Visible = True

'Create a new empty document
objWord.Documents.Add
'Or open an existing document
'objWord.Documents.Open (&quot;c:\WordOutput.doc&quot;)

'Paste text from textarea of the html form
'You will need to elaborate that part
'if you are not using textarea
objWord.Selection.TypeText strText

'Selection also can be formatted

'If you want PrintPreview Command
'objWord.ActiveDocument.PrintPreview

'Invoke printing command in background
'Printout will print directly to the printer
'Without asking anything
objWord.PrintOut

'There are many parameters of PrintOut
'you can check them in MSDN

'If you are using more than one copy of Word
'you would like to close after finishing
'but it needs also checking if the printing is done
'objWord.Quit


'Clean up the memory
Set objWord = Nothing
End Sub
</script>

</head>
<body>
<textarea name=&quot;content&quot;></textarea>
<input type=&quot;button&quot; value=&quot;Print&quot; onClick=&quot;printTextViaWord(content.value)&quot;>
</body>
</html>

Hope this helps.
D.

You could try your question in the forum VBA (Visual Basic for applications).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top