473,888 Members | 1,816 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Printing a word document from web form

2 New Member
Hi All,

I am trying to first edit and then print a word document (saved on web server). The code works fine in debug mode, but when i deploy this to web server, then i get the following error.

Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80070005.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Unauthor izedAccessExcep tion: Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80070005.

ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNE T on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="tr ue"/>, the identity will be the anonymous user (typically IUSR_MACHINENAM E) or the authenticated request user.

To grant ASP.NET access to a file, right-click the file in Explorer, choose "Properties " and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.


Here is the code.

Expand|Select|Wrap|Line Numbers
  1. Dim missing As Object = System.Reflection.Missing.Value
  2.  
  3.         ' Dim filename As String = Request.ServerVariables("PATH_INFO") & "/" & System.Configuration.ConfigurationManager.AppSettings("filename")
  4.         Dim filename As Object = System.Configuration.ConfigurationManager.AppSettings("website") & System.Configuration.ConfigurationManager.AppSettings("filename")
  5.         ' template file name
  6.         Dim newTemplate As Object = False
  7.         Dim docType As Object = 0
  8.         Dim isVisible As Object = True
  9.         Dim [readOnly] As Object = False
  10.  
  11.  
  12. Dim aDoc As Word.Document = WordApp.Documents.Open(filename, missing, [readOnly], missing, missing, missing, missing, missing, missing, missing, missing, isVisible) ' Activate the document so it shows up in front aDoc.Activate();
  13.             ' Add the copyright text and a line break
  14.             aDoc.Bookmarks.Item("CaseNo").Range.Text = casenumber
  15.             aDoc.Bookmarks.Item("Technician").Range.Text = ownername
  16.             aDoc.Bookmarks.Item("Date").Range.Text = printdate
  17.             aDoc.PrintOut()
Please help. This is very urgent.

Thanks in advance.
Ashwani
Mar 3 '07 #1
2 1919
kenobewan
4,871 Recognized Expert Specialist
I assume that you have the .net framework is installed.

Open start->settings->control panel -> Users and password (on W2K).
Or right click the folder(s) you which to share. Choose the sharing tab,
and then the permissions button. On the new dialog click add. Choose look in "your computer name". Find the ASPNET user in the list!

If there is no ASPNET user i would check if you have .NET and ASPNET
installed at all. Please post result.
Mar 3 '07 #2
ashwanir
2 New Member
Hi,

Thanks for your reply. I have ASPNET installed on the server. Now instead of saving the documents, i am directly sending it to printer and looks like it is working now. I have not yet tested on the server.

Will post again, once i am done with full testing.

Thanks.
Mar 10 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1580
by: Raju Joseph | last post by:
Hi All, I have a small problem at hand and am looking for suggestions. I have created a wrapper for word 2000 for our application which is in VB.NET 2003. Everything works fine in the sense that users are able to save documents through our application using word 2000 as the editor. I have written for word 2000 sothat the code works for other higher versions of word.
9
2334
by: Tony Williams | last post by:
I have an Access database that we use as a document index system. The documents can be Word, Excel, pdf's etc I have a command button on a form that opens the document in whatever program is relevant. The code I use is Private Sub Cmdstart_Click() On Error GoTo Err_Handler Dim strPath As String If IsNull(DocURLtxt.Value) Then strmsg = "You must enter the Document URL to use this function
5
3359
by: Stefania Scott | last post by:
I am trying to print a word document from Access. The code I've written works well in my computer but does not in the one were it is needed. Here the piece of code: 'doc path strObjectPath = "P:\2004worksheets\IIS_WS.doc" Set oWord = New Word.Application oWord.Documents.Add (strObjectPath) oWord.PrintOut
0
1080
by: Bill | last post by:
Hi all, I have developed a component to wrap MS-Word, and I use this to manage my reports. It´s a simple components, but it´s very useful...to eliminate this very tiresome declarations like this: Object flag = Type.Missing; bla, bla, and things like this...
4
2080
by: scorpion53061 | last post by:
I have my Word document being created in a seperate thread. THe applicaiton is not visible. The end user can choose to view the document upon completion or just have it print. Viewing is fine. If htey choose to "just print it" it seems ot ignore this command:
1
5729
by: hamil | last post by:
I am trying to print a graphic file (tif) and also use the PrintPreview control, the PageSetup control, and the Print dialog control. The code attached is a concatination of two examples taken out of a Microsoft book, "Visual Basic,Net Step by Step" in Chapter 18. All but the bottom two subroutines will open a text file, and then allow me to use the above controls, example 1. The bottom two subroutines will print a graphic file, example...
1
7552
by: Laurent Navarro | last post by:
Hi, I created a C# application which opens a Word document, fills some fields and sends the whole document to the printer. Everything is working great but I find the printing step very slow. Each printing order takes about 2 or 3 seconds to complete which can be long when you have 200 different documents to print. I'm using Word because I want the users to be able to easily create some templates containing specials fields that the...
2
1301
by: madval | last post by:
hi, i need your help, i'll receive some ms word documents (paragraphs, bullets, different fonts in a document -family-size-format, images, etc. a "normal" document) and i need to print them on a preprinted sheet that have 2 sections for printing data. +------------------------------------------+ | | | +----------------------------------+ | | | | | | | ...
0
1248
by: Iain Wilson | last post by:
I am pulling my hair out trying to print various objects from a .net web page My apologies for cross posting but I need an answer and my previous post has attracted no interest. ASP.Net 2.0 using C# This is a simple web page on our intranet (written as a test) and all I am trying to do is print a document to a named printer. If I use a StreamReader then I get an output to the printer. This
7
2574
by: Iain Wilson | last post by:
I am pulling my hair out trying to print various objects from a .net web page My apologies for cross posting but I need an answer and my previous post has attracted no interest. ASP.Net 2.0 using C# This is a simple web page on our intranet (written as a test) and all I am trying to do is print a document to a named printer. If I use a StreamReader then I get an output to the printer. This
0
9959
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9800
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11176
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10880
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9593
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7988
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5812
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6012
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3246
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.