Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to get cell color in excel using vb.net

Posted on 2004-08-03
4
Medium Priority
?
14,041 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

610 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