Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 21st, 2004, 11:26 AM
Friend of Wrox
 
Join Date: Sep 2003
Location: Whitstable, , United Kingdom.
Posts: 121
Thanks: 0
Thanked 0 Times in 0 Posts
Default printing a word doc from

hi,
    can anyone point me to an example of how i can print off
    a word document from server side vb/asp.net code ?

    i want to be able to edit the word.doc (eg set name & address
    details) and then printit off.

any and all help muchly appreciated

cheers
chas

 
Old December 28th, 2004, 06:03 AM
Registered User
 
Join Date: Dec 2004
Location: Salamanca, Castilla y Leon, Spain.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

I have to do the same process. I have been able to open, edit and close a word document. But, when I want to print it from a web project, i can't do it. I have tried to do it from a Windows project and I have done it.
This is the code:

Public Sub SendToPrinter()
            Dim oEnum1 As New Word.WdPrintOutPages
            Dim oEnum2 As New Word.WdPrintOutItem
            Dim oEnum3 As New Word.WdPrintOutRange

            Dim oWordApp As Word.ApplicationClass

            Try
                oWordApp = New Word.ApplicationClass

                oWordApp.ActivePrinter = Me.LocalPrinterName

                _word = oWordApp.Documents.Open(CObj(Me.WordPath))

                _word.PrintOut(Background:=False, Append:=False, Range:=oEnum3.wdPrintAllDocument, Item:=oEnum2.wdPrintDocumentContent, Copies:=1, PageType:=oEnum1.wdPrintAllPages, PrintToFIle:=False)

                _word.Close()
                oWordApp.Quit()
            Catch ex As Exception
                If Not Me._word Is Nothing Then
                    _word.Close()
                End If
                If Not oWordApp Is Nothing Then
                    oWordApp.Quit()
                End If

            Finally
                Marshal.ReleaseComObject(oWordApp)
            End Try
        End Sub

It works in windows project but not in web project. why???

Julián Sanz
Microsoft Technology Group
GPM Factoría Internet
(923) 100 300
http://www.gpm.es
 
Old December 13th, 2013, 07:06 AM
Registered User
Points: 21, Level: 1
Points: 21, Level: 1 Points: 21, Level: 1 Points: 21, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2013
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Re: printing a word doc from

Hi jsanzg, well the problem is that you are trying to use .NETs Word Interop on server side and I believe that the server you are using does not have MS Word installed. So unfortunately you will have to change your approach or install Office on server, but note that Microsoft does not recommend, and does not support, Automation of Microsoft Office applications on server side.

I would recommend you to try some approach that does not have any dependecy to MS Word, for example I used this VB.NET Word component.
You can easily open, edit and save your word document and also you can print word files in .NET like the following:
Code:
' Print Word file (DOCX or DOC) to the default printer.
DocumentModel.Load("Document.doc").Print()




Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating word doc - word behaviour mat41 Classic ASP Professional 2 April 29th, 2007 06:46 PM
Printing .doc file in asp automatically vishalres Classic ASP Professional 3 April 9th, 2007 05:56 PM
Copy text from 1 doc to other doc thru vba in word itchock Word VBA 2 December 29th, 2006 02:47 AM
Printing To Word Doc kekohchaa VS.NET 2002/2003 0 May 7th, 2004 03:35 AM
Copy word to word doc. in VB vamshi Pro VB 6 1 March 24th, 2004 06:25 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.