Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET 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 February 18th, 2008, 06:33 AM
Registered User
 
Join Date: Feb 2008
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Exception from HRESULT: 0x800A03EC

Hi friend plz help me

i m putting data from a dataset to an excel file in windows application.


after setting value of 2 cells
i m getting this error : Exception from HRESULT: 0x800A03EC


the code is

Dim MyExcel As New Microsoft.Office.Interop.Excel.Application
        Try
            MyExcel.Workbooks.Open(Application.StartupPath() & "\Preview\WorkSheet1.xls")
        Catch ex As Exception
            MsgBox("Open : " & ex.Message)
            MyExcel = Nothing
        End Try

        MyExcel.ActiveWorkbook.ActiveSheet.Cells(5, 1) = ("Party Ledger for Party " & ds.Tables(0).Rows(0).Item("PartyName"))
        MyExcel.ActiveWorkbook.ActiveSheet.Cells(6, 1) = ("From " & CDate(ds.Tables(0).Rows(0).Item("Date")).Date & " To " & CDate(ds.Tables(0).Rows(ds.Tables(0).Rows.Count - 1).Item("Date")).Date)

        Dim rows As Integer = 8
        Dim TotalDr As Decimal = 0
        Dim TotalCr As Decimal = 0
        For i As Integer = 0 To ds.Tables(0).Rows.Count - 1
            MyExcel.ActiveWorkbook.ActiveSheet.Cells(8 + i, 0) = i + 1
' getting error here
      MyExcel.ActiveWorkbook.ActiveSheet.Cells(8 + i, 1) = ds.Tables(0).Rows(i).Item("Description")
            MyExcel.ActiveWorkbook.ActiveSheet.Cells(8 + i, 2) = ds.Tables(0).Rows(i).Item("Date")
            If ds.Tables(0).Rows(i).Item("Type") = "Sales" Or ds.Tables(0).Rows(i).Item("Type") = "Issue" Then
                MyExcel.ActiveWorkbook.ActiveSheet.Cells(8 + i, 3) = CDbl(ds.Tables(0).Rows(i).Item("Ammount"))
                TotalDr = totaldr + CDbl(ds.Tables(0).Rows(i).Item("Ammount"))
            Else
                MyExcel.ActiveWorkbook.ActiveSheet.Cells(8 + i, 3) = ""
            End If
            If ds.Tables(0).Rows(i).Item("Type") = "Purchase" Or ds.Tables(0).Rows(i).Item("Type") = "Receive" Then
                MyExcel.ActiveWorkbook.ActiveSheet.Cells(8 + i, 4) = CDbl(ds.Tables(0).Rows(i).Item("Ammount"))
                TotalCr = TotalCr + CDbl(ds.Tables(0).Rows(i).Item("Ammount"))
            Else
                MyExcel.ActiveWorkbook.ActiveSheet.Cells(8 + i, 4) = ""
            End If
            If ds.Tables(0).Rows(i).Item("ClosingBalance") < 0 Then
                MyExcel.ActiveWorkbook.ActiveSheet.Cells(8 + i, 5) = ds.Tables(0).Rows(i).Item("ClosingBalance") & " Cr"
            ElseIf ds.Tables(0).Rows(i).Item("ClosingBalance") > 0 Then
                MyExcel.ActiveWorkbook.ActiveSheet.Cells(8 + i, 5) = ds.Tables(0).Rows(i).Item("ClosingBalance") & " Dr"
            End If
            rows = rows + i
        Next
        Dim fpath As String
        Try
            fpath = Application.StartupPath() & "WorkSheet1" & Date.Today.Day * Date.Today.Second & "" & ds.Tables(0).Rows(0).Item("PartyName") & ".xls"
            MyExcel.ActiveWorkbook.SaveAs(fpath)
            MsgBox("File Saved successfully")
        Catch ex As Exception
            MsgBox("Problem occur during saving report, Please Try Again.")
            MyExcel = Nothing
        Finally
            MyExcel.ActiveWorkbook.Close(False, Application.StartupPath() & "\Preview\SuccessRateByPayer.xls")
            MyExcel.DisplayAlerts = False
            MyExcel = Nothing
        End Try

    End Sub







Similar Threads
Thread Thread Starter Forum Replies Last Post
Error 'Exception from HRESULT: 0x800A03EC' vipin_pc ASP.NET 2.0 Professional 3 November 6th, 2009 09:17 AM
Needhelp Error- Exception from HRESULT: 0x800A0057 remya1000 General .NET 1 November 6th, 2008 11:45 AM
access denied. [exception from HRESULT: 0x80070005 p2ptolu Internet Information Services 0 December 18th, 2007 02:58 PM
Exception from HRESULT : 0x800A2740. remya1000 .NET Framework 1.x 0 November 8th, 2007 04:29 PM
Exception from HRESULT: 0x80131524. kschori Crystal Reports 0 May 7th, 2004 03:27 PM





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