Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to set the backcolor of MS Excel cells

How to set the backcolor of MS Excel cells

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    freeman868
    wrote on last edited by
    #1

    I'am trying to use VC to operate Ms Excel, but I can't set the back color of cells, what can I do for it?

    freeman

    F 1 Reply Last reply
    0
    • F freeman868

      I'am trying to use VC to operate Ms Excel, but I can't set the back color of cells, what can I do for it?

      freeman

      F Offline
      F Offline
      fefe wyx
      wrote on last edited by
      #2

      Here's a code segment written in VB

          With Selection.Interior
              .ColorIndex = 3  ' this is red ...
              .Pattern = xlSolid
          End With
      

      I think it it easy to know how to do it in VC from that. By the way, there is a way to know how to get some work accomplished in your codes: just open Excel, and record a macro doing just the same thing, then you can check the code in Excel's Macro editor. I got that piece of code in this way.

      F 1 Reply Last reply
      0
      • F fefe wyx

        Here's a code segment written in VB

            With Selection.Interior
                .ColorIndex = 3  ' this is red ...
                .Pattern = xlSolid
            End With
        

        I think it it easy to know how to do it in VC from that. By the way, there is a way to know how to get some work accomplished in your codes: just open Excel, and record a macro doing just the same thing, then you can check the code in Excel's Macro editor. I got that piece of code in this way.

        F Offline
        F Offline
        freeman868
        wrote on last edited by
        #3

        Good idear! I have solved my problem! Thank u! And do it in VC just need to add some codes follow: Interior bkColor; bkColor.AttachDispatch(range.GetInterior().pdispVal) bkColor.SetColor(COleVariant((long)0x000000)); //black Also Give Thank to a friend named ◎Alpha◎ who helped me, God will bless him and his family!:)

        freeman

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups