Solved

How to get cell color in excel using vb.net

Posted on 2004-08-03
4
13,997 Views
Last Modified: 2012-06-21
I would like to print the cell colorof excel sheet. I did code in VB.NET it opens the .xls file from desired location, and print in msgbox the cell value.

Now, I would like to see the cell back color, and font color using msgbox.

How can I proceed?

Here the existing code. Pls reference excel object 9.0 before run this code in VB.NEt enviromment.

''Inherits System.Runtime.InteropServices.COMException
Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(292, 266)
        Me.Name = "Form1"
        Me.Text = "Excel"

    End Sub

#End Region

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim objExcel As New Excel.Application
        Dim objWrkBk As Excel.Workbook
        Dim objSht As Excel.Worksheet
        Dim objRng As Excel.Range
        Dim strCol, strCell As String
        Dim maxCol, maxRow As Integer
        Dim iRow, iCol As Integer
        maxRow = 2
        maxCol = 2
        objWrkBk = objExcel.Workbooks.Open("C:\test.xls")
        objSht = objWrkBk.Worksheets(1)
        objExcel.Visible = True
        For iCol = 1 To maxCol
            For iRow = 1 To maxRow
                strCol = Chr(Asc(iRow) + 16)
                strCell = strCol + iCol.ToString
                objRng = objSht.Range(strCell)
                MsgBox(objRng.Value)
            Next
        Next


    End Sub
End Class



Thanks in advanced.
0
Comment
Question by:himadrish
4 Comments
 

Accepted Solution

by:
sungs earned 150 total points
Comment Utility
0
 

Author Comment

by:himadrish
Comment Utility
Still not any good feasible solltion come out.

Thanks all for your kind attention.

Himadrish
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now