Excel Work Book Open Issuehttp://forums.asp.net/t/1744004.aspx/1?Excel+Work+Book+Open+IssueFri, 02 Dec 2011 06:15:21 -050017440044703685http://forums.asp.net/p/1744004/4703685.aspx/1?Excel+Work+Book+Open+IssueExcel Work Book Open Issue <p>Hi All,</p> <p>&nbsp; When I am open Excel through work book I got the below error</p> <p><strong>Exception from HRESULT: 0x800A03EC</strong></p> <p>I am posting my code Below</p> <p>&nbsp;Dim xlApp As New xl.Application<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim oldCulture As System.Globalization.CultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'Initialize Excel<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo(&quot;en-us&quot;)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Try<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'Open and unlock the Excel document<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ''&nbsp; xlApp.Workbooks.Open(path)&nbsp; <strong>// Here I got the error</strong><br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim wb As xl.Workbook<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim ws As xl.Worksheet<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xlApp.Workbooks.Open(path)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wb = xlApp.Workbooks(1)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ws = DirectCast(wb.Worksheets(1), xl.Worksheet)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ws.Unprotect()<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xlApp.Visible = True<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Catch ex As Exception<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim innerException As String = String.Empty<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If Not ex.InnerException Is Nothing Then innerException = ex.InnerException.Message<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MessageBox.Show(BCConstants.ERROR_HEADER_DEFAULT &#43; &quot;&nbsp; &quot; &#43; ex.Message &#43; vbCrLf &#43; innerException &#43; vbCrLf &#43; BCConstants.ERROR_MESSAGE_GENERAL, &quot;PCCT&quot;, MessageBoxButtons.OK, MessageBoxIcon.Error)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If Not xlApp Is Nothing Then<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If xlApp.Workbooks.Count &gt; 0 Then xlApp.Workbooks(1).Saved = True 'Avoid questions when quitting excel<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xlApp.Quit()<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xlApp = Nothing<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GC.Collect()<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Finally</p> <p>Thanks in Advance.</p> <p>Regards,</p> <p>Naresh.Pydi</p> <p>&nbsp;</p> <p>&nbsp;</p> <p>&nbsp;</p> <p><strong></strong>&nbsp;</p> 2011-11-28T05:33:27-05:004703812http://forums.asp.net/p/1744004/4703812.aspx/1?Re+Excel+Work+Book+Open+IssueRe: Excel Work Book Open Issue <p>what is the path?</p> <p>And please try</p> <p>&nbsp;Dim xlApp As xl.Application</p> <p>set xlApp&nbsp; = new xl.Application</p> <p>Does the set line throws same error?</p> <p></p> 2011-11-28T06:41:18-05:004703884http://forums.asp.net/p/1744004/4703884.aspx/1?Re+Excel+Work+Book+Open+IssueRe: Excel Work Book Open Issue <p>&nbsp;</p> <p>Hi</p> <p>Thanks for Your reply..</p> <p>I am trying with your suggestion but its still showing the same error and the path is below...</p> <p>&nbsp;Friend Sub ExportToExcel()<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim path As String<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim LOGON32_LOGON_INTERACTIVE As Integer = 2<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim LOGON32_PROVIDER_DEFAULT As Integer = 0<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; path = GetUniqueFileName()<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Utils.CheckAndCreateFolders(path)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UnhideColumns()<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'ClearAllFilters()<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim officeVersion As String = Utils.GetOfficeVersion()<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If officeVersion = BCConstants.OFFICE_VERSION_2010_14 Then<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; costEstimateFpSpread.SaveExcel(path, FarPoint.Excel.ExcelSaveFlags.UseOOXMLFormat Or FarPoint.Excel.ExcelSaveFlags.SaveCustomColumnHeaders)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Else<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; costEstimateFpSpread.SaveExcel(path, FarPoint.Win.Spread.Model.IncludeHeaders.ColumnHeadersCustomOnly)</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; HideColumns()<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OpenAndUnlockExcel(path)</p> <p>&nbsp;&nbsp;&nbsp; End Sub</p> <p>&nbsp;</p> <p>Regrads,</p> <p>Naresh.Pydi</p> 2011-11-28T07:36:24-05:004703909http://forums.asp.net/p/1744004/4703909.aspx/1?Re+Excel+Work+Book+Open+IssueRe: Excel Work Book Open Issue <p>the same error in the same line or in another line ( the</p> <p>set</p> <p>line</p> <p>)</p> <p>?</p> <p>ANd what's</p> <p>path = GetUniqueFileName()</p> <p>It's an api or code in your project? Where does creates...?</p> 2011-11-28T07:54:42-05:004703920http://forums.asp.net/p/1744004/4703920.aspx/1?Re+Excel+Work+Book+Open+IssueRe: Excel Work Book Open Issue <p>Same Line and the Path is My Local Folder .........</p> 2011-11-28T07:59:55-05:004703980http://forums.asp.net/p/1744004/4703980.aspx/1?Re+Excel+Work+Book+Open+IssueRe: Excel Work Book Open Issue <p></p> <blockquote><span class="icon-blockquote"></span> <h4>suresh.pydi</h4> Path is My Local Folder .........</blockquote> <p></p> <p>FOr asp.net it does not exists &quot;my local folder&quot;. Please make a folder in the website, put read/write attributes and make there your work</p> 2011-11-28T08:27:39-05:004704029http://forums.asp.net/p/1744004/4704029.aspx/1?Re+Excel+Work+Book+Open+IssueRe: Excel Work Book Open Issue <p>Hi,</p> <p>&nbsp;I did n't get you My local path means</p> <p><strong>C:\Documents and Settings\v0c1524\Local Settings\Temp\PCCT</strong></p> <p>and I am using VB.net not Asp.net</p> <p>&nbsp;</p> <p>Regards,</p> <p>Naresh.Pydi</p> <p>&nbsp;</p> 2011-11-28T08:58:50-05:004704135http://forums.asp.net/p/1744004/4704135.aspx/1?Re+Excel+Work+Book+Open+IssueRe: Excel Work Book Open Issue <p></p> <blockquote><span class="icon-blockquote"></span> <h4>suresh.pydi</h4> and I am using VB.net not Asp.net</blockquote> <br> What kind of application do you have? WCF&nbsp; ? Windows Forms? WebForms? MVC ? Other? <p></p> 2011-11-28T09:48:58-05:004704159http://forums.asp.net/p/1744004/4704159.aspx/1?Re+Excel+Work+Book+Open+IssueRe: Excel Work Book Open Issue <p>Hi ,</p> <p>&nbsp;Thank you so much for your Replies</p> <p>and I am using Winforms... and the problem it comes when I am doing some Filters in spreadsheet at that time I am Importing the Data into Excel File</p> <p>Regards,</p> <p>Naresh.Pydi</p> 2011-11-28T10:02:42-05:004705139http://forums.asp.net/p/1744004/4705139.aspx/1?Re+Excel+Work+Book+Open+IssueRe: Excel Work Book Open Issue <p>http://www.made4dotnet.com/Default.aspx?tabid=141&amp;aid=15</p> 2011-11-28T17:43:39-05:004705671http://forums.asp.net/p/1744004/4705671.aspx/1?Re+Excel+Work+Book+Open+IssueRe: Excel Work Book Open Issue <p>HI,</p> <p>&nbsp; I already tried with this Link but its not helpful for me...</p> <p>&nbsp;</p> <p>Regards,</p> <p>Naresh.Pydi</p> 2011-11-29T04:06:56-05:004706327http://forums.asp.net/p/1744004/4706327.aspx/1?Re+Excel+Work+Book+Open+IssueRe: Excel Work Book Open Issue <p>Hi,</p> <p>&nbsp; Anyone have any Idea about Disable the filters in Excel In VB.Net I need disable the filters before Open the Excel File</p> <p>Regards,</p> <p>Naresh.Pydi</p> 2011-11-29T10:43:29-05:004711586http://forums.asp.net/p/1744004/4711586.aspx/1?Re+Excel+Work+Book+Open+IssueRe: Excel Work Book Open Issue <p>Hi,</p> <p>You can refer to the below link about the question. The same question you have posted again.</p> <p><a href="../../../../p/1744514/4711570.aspx/1?p=True&amp;t=634583881501574410">http://forums.asp.net/p/1744514/4711570.aspx/1?p=True&amp;t=634583881501574410</a></p> 2011-12-02T06:15:21-05:00