?
Solved

How to get cell color in excel using vb.net

Posted on 2004-08-03
4
Medium Priority
?
14,033 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 

Accepted Solution

by:
sungs earned 600 total points
ID: 11712363
0
 

Author Comment

by:himadrish
ID: 12345761
Still not any good feasible solltion come out.

Thanks all for your kind attention.

Himadrish
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

801 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