Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#3.0
This is the error as shown below while doing a page count:
Server Error in '/recordsmanagement' Application.
Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).
Exception Details: System.UnauthorizedAccessException: Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)). Source Error:
 

Line 387: Microsoft.Office.Interop.Word.ApplicationClass WordApp = new Microsoft.Office.Interop.Word.ApplicationClass();//error referencing to this line.
 
all the refereencing has been done and was working fine on the production machine..here is the full code of the web application doing page count:
 
Microsoft.Office.Interop.Word.ApplicationClass WordApp = new Microsoft.Office.Interop.Word.ApplicationClass();

 
// give any file name of your choice.
string tempath = numberofpage;
RegexOptions options = RegexOptions.None;
Regex regex = new Regex(@"[ ]{2,}", options);
tempath = regex.Replace(tempath, @"");
tempath = tempath.Replace(" \\", "\\");
object fileName = tempath;
object readOnly = false;
object isVisible = true;
 
// the way to handle parameters you don't care about in .NET
object missing = System.Reflection.Missing.Value;
object objDNS = Microsoft.Office.Interop.Word.WdSaveOptions.wdDoNotSaveChanges;
 
// Make word visible, so you can see what's happening
//WordApp.Visible = true;
// Open the document that was chosen by the dialog
Microsoft.Office.Interop.Word.Document aDoc = WordApp.Documents.Open(ref fileName,
ref missing, ref readOnly, ref missing,
ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing,
ref missing, ref isVisible);
 
Microsoft.Office.Interop.Word.WdStatistic stat = Microsoft.Office.Interop.Word.WdStatistic.wdStatisticPages;
count = aDoc.ComputeStatistics(stat, ref missing);
 
WordApp.Quit(ref objDNS, ref missing, ref missing);
 
aDoc = null;
 
WordApp = null;
 
GC.Collect();
So far i have not found a solution to it
Posted 7-Nov-12 10:30am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 545
1 CPallini 490
2 George Jonsson 291
3 OriginalGriff 260
4 Suvabrata Roy 219
0 OriginalGriff 4,873
1 CPallini 3,900
2 Sergey Alexandrovich Kryukov 3,474
3 George Jonsson 2,646
4 Gihan Liyanage 2,236


Advertise | Privacy | Mobile
Web02 | 2.8.140905.1 | Last Updated 7 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100