p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > .NET > Other .NET > General .NET
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 18th, 2008, 06:33 AM
Registered User
 
Join Date: Feb 2008
Location: Delhi, , India.
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


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

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 04:27 PM



All times are GMT -4. The time now is 04:09 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc