Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 16th, 2008, 02:16 PM
Authorized User
 
Join Date: Apr 2008
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default Javascript print function

Does anyone know how to convert this code into javascript so I can print the document client-side?

        Dim WordObj As word.Application
        WordObj = CreateObject("Word.Application")
        Dim objWord As word.Document
        Dim FilePath As String = MapPath("TSPrintWeb.doc")
        objWord = WordObj.Documents.Open(FileName:=FilePath, ReadOnly:=True)
        WordObj.Visible = False

        With objWord.Bookmarks
            Select Case rdoEFF.SelectedItem.Value
                Case 3
                    .Item("EFF").Range.Text = txtEFF.Text

                Case 2
                    .Item("EFF").Range.Text = "Avio NG"

                Case 1
                    .Item("EFF").Range.Text = "Avidyne"

                Case 0
                    .Item("EFF").Range.Text = "All aircraft"
            End Select

            .Item("ATACHAP").Range.Text = txtChapter.Text
            .Item("ATASECT").Range.Text = txtSection.Text
            .Item("CAS").Range.Text = cboCAS.SelectedItem.Text
            .Item("FAULT").Range.Text = txtFAULT.Text
            .Item("CAUSE").Range.Text = txtCAUSE.Text
            .Item("STEP").Range.Text = txtSTEPS.Text
        End With

objWord.PrintOut()
        objWord = Nothing

The code worked fine until the page it was in was deployed to the company network. It took awhile to figure out the code behind page (which is where this code originally was) is run at the server. So, I need it to run at the client for it to work.

Thanks,

Chris


  #2 (permalink)  
Old September 17th, 2008, 05:40 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You might be better off creating a document stream of the word doc on the server side, then sending the result to the browser. Typically a custom handler (ashx) would be the "page" that delivers this form of information.

You may also run into problems running office apps in a server environment. I'm not sure what the licensing rules about this are so you might want to check on that too.

-Peter
compiledthoughts.com
  #3 (permalink)  
Old September 27th, 2008, 12:56 PM
Authorized User
 
Join Date: Apr 2008
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Problem solved. I abandoned the MS Word approach and just created a print web page with a dynamically created table. Doing that solved my original problem of how to automatically size fields to the respective text content (which was the reason I used Word in the first place). While it now requires an extra step at the client side to actually print the document the user now has the ability to choose which printer to use instead of only the default.

Thanks for the help, though.

Chris


 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
stop current javascript function using javascript sakthi Javascript 3 June 2nd, 2008 03:30 PM
javascript print in landscape vsr Javascript How-To 0 November 14th, 2007 05:23 PM
PRINT function kuku HTML Code Clinic 10 October 9th, 2006 07:02 AM
How to call javascript function from VB function vinod_yadav1919 VB How-To 0 February 13th, 2006 06:03 AM
How to use Print Hidden Function kiwibey Javascript 6 May 12th, 2005 11:38 AM



All times are GMT -4. The time now is 05:56 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.