When I am open Excel through work book I got the below error
Exception from HRESULT: 0x800A03EC
I am posting my code Below
Dim xlApp As New xl.Application
Dim oldCulture As System.Globalization.CultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture
'Initialize Excel
System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo("en-us")
Try
'Open and unlock the Excel document
'' xlApp.Workbooks.Open(path) // Here I got the error
Dim wb As xl.Workbook
Dim ws As xl.Worksheet
xlApp.Workbooks.Open(path)
wb = xlApp.Workbooks(1)
ws = DirectCast(wb.Worksheets(1), xl.Worksheet)
ws.Unprotect()
xlApp.Visible = True
Catch ex As Exception
Dim innerException As String = String.Empty
If Not ex.InnerException Is Nothing Then innerException = ex.InnerException.Message
MessageBox.Show(BCConstants.ERROR_HEADER_DEFAULT + " " + ex.Message + vbCrLf + innerException + vbCrLf + BCConstants.ERROR_MESSAGE_GENERAL, "PCCT", MessageBoxButtons.OK, MessageBoxIcon.Error)
If Not xlApp Is Nothing Then
If xlApp.Workbooks.Count > 0 Then xlApp.Workbooks(1).Saved = True 'Avoid questions when quitting excel
xlApp.Quit()
xlApp = Nothing
GC.Collect()
End If
Finally
I am trying with your suggestion but its still showing the same error and the path is below...
Friend Sub ExportToExcel()
Dim path As String
Dim LOGON32_LOGON_INTERACTIVE As Integer = 2
Dim LOGON32_PROVIDER_DEFAULT As Integer = 0
path = GetUniqueFileName()
Utils.CheckAndCreateFolders(path)
UnhideColumns()
'ClearAllFilters()
Dim officeVersion As String = Utils.GetOfficeVersion()
If officeVersion = BCConstants.OFFICE_VERSION_2010_14 Then
costEstimateFpSpread.SaveExcel(path, FarPoint.Excel.ExcelSaveFlags.UseOOXMLFormat Or FarPoint.Excel.ExcelSaveFlags.SaveCustomColumnHeaders)
Else
costEstimateFpSpread.SaveExcel(path, FarPoint.Win.Spread.Model.IncludeHeaders.ColumnHeadersCustomOnly)
suresh.pydi
Member
135 Points
185 Posts
Excel Work Book Open Issue
Nov 28, 2011 05:33 AM|LINK
Hi All,
When I am open Excel through work book I got the below error
Exception from HRESULT: 0x800A03EC
I am posting my code Below
Dim xlApp As New xl.Application
Dim oldCulture As System.Globalization.CultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture
'Initialize Excel
System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo("en-us")
Try
'Open and unlock the Excel document
'' xlApp.Workbooks.Open(path) // Here I got the error
Dim wb As xl.Workbook
Dim ws As xl.Worksheet
xlApp.Workbooks.Open(path)
wb = xlApp.Workbooks(1)
ws = DirectCast(wb.Worksheets(1), xl.Worksheet)
ws.Unprotect()
xlApp.Visible = True
Catch ex As Exception
Dim innerException As String = String.Empty
If Not ex.InnerException Is Nothing Then innerException = ex.InnerException.Message
MessageBox.Show(BCConstants.ERROR_HEADER_DEFAULT + " " + ex.Message + vbCrLf + innerException + vbCrLf + BCConstants.ERROR_MESSAGE_GENERAL, "PCCT", MessageBoxButtons.OK, MessageBoxIcon.Error)
If Not xlApp Is Nothing Then
If xlApp.Workbooks.Count > 0 Then xlApp.Workbooks(1).Saved = True 'Avoid questions when quitting excel
xlApp.Quit()
xlApp = Nothing
GC.Collect()
End If
Finally
Thanks in Advance.
Regards,
Naresh.Pydi
ignatandrei
All-Star
137682 Points
22147 Posts
Moderator
MVP
Re: Excel Work Book Open Issue
Nov 28, 2011 06:41 AM|LINK
what is the path?
And please try
Dim xlApp As xl.Application
set xlApp = new xl.Application
Does the set line throws same error?
suresh.pydi
Member
135 Points
185 Posts
Re: Excel Work Book Open Issue
Nov 28, 2011 07:36 AM|LINK
Hi
Thanks for Your reply..
I am trying with your suggestion but its still showing the same error and the path is below...
Friend Sub ExportToExcel()
Dim path As String
Dim LOGON32_LOGON_INTERACTIVE As Integer = 2
Dim LOGON32_PROVIDER_DEFAULT As Integer = 0
path = GetUniqueFileName()
Utils.CheckAndCreateFolders(path)
UnhideColumns()
'ClearAllFilters()
Dim officeVersion As String = Utils.GetOfficeVersion()
If officeVersion = BCConstants.OFFICE_VERSION_2010_14 Then
costEstimateFpSpread.SaveExcel(path, FarPoint.Excel.ExcelSaveFlags.UseOOXMLFormat Or FarPoint.Excel.ExcelSaveFlags.SaveCustomColumnHeaders)
Else
costEstimateFpSpread.SaveExcel(path, FarPoint.Win.Spread.Model.IncludeHeaders.ColumnHeadersCustomOnly)
End If
HideColumns()
OpenAndUnlockExcel(path)
End Sub
Regrads,
Naresh.Pydi
ignatandrei
All-Star
137682 Points
22147 Posts
Moderator
MVP
Re: Excel Work Book Open Issue
Nov 28, 2011 07:54 AM|LINK
the same error in the same line or in another line ( the
set
line
)
?
ANd what's
path = GetUniqueFileName()
It's an api or code in your project? Where does creates...?
suresh.pydi
Member
135 Points
185 Posts
Re: Excel Work Book Open Issue
Nov 28, 2011 07:59 AM|LINK
Same Line and the Path is My Local Folder .........
ignatandrei
All-Star
137682 Points
22147 Posts
Moderator
MVP
Re: Excel Work Book Open Issue
Nov 28, 2011 08:27 AM|LINK
FOr asp.net it does not exists "my local folder". Please make a folder in the website, put read/write attributes and make there your work
suresh.pydi
Member
135 Points
185 Posts
Re: Excel Work Book Open Issue
Nov 28, 2011 08:58 AM|LINK
Hi,
I did n't get you My local path means
C:\Documents and Settings\v0c1524\Local Settings\Temp\PCCT
and I am using VB.net not Asp.net
Regards,
Naresh.Pydi
ignatandrei
All-Star
137682 Points
22147 Posts
Moderator
MVP
Re: Excel Work Book Open Issue
Nov 28, 2011 09:48 AM|LINK
What kind of application do you have? WCF ? Windows Forms? WebForms? MVC ? Other?
suresh.pydi
Member
135 Points
185 Posts
Re: Excel Work Book Open Issue
Nov 28, 2011 10:02 AM|LINK
Hi ,
Thank you so much for your Replies
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
Regards,
Naresh.Pydi
ignatandrei
All-Star
137682 Points
22147 Posts
Moderator
MVP
Re: Excel Work Book Open Issue
Nov 28, 2011 05:43 PM|LINK
http://www.made4dotnet.com/Default.aspx?tabid=141&aid=15