+ Reply to Thread
Results 1 to 7 of 7

Correct syntax for Gradient fill of shape

  1. #1
    Forum Contributor
    Join Date
    01-02-2007
    Location
    Australia NSW
    MS-Off Ver
    2013
    Posts
    494

    Correct syntax for Gradient fill of shape

    As part of a major report, i need to change the color/s of a prenamed shape.

    I need to color fill the shape as gradient in 2 colors.
    I tried the following googled code, but i get an error with it.

    Can anyone assist in the correct gradient fill syntax for the beloiw:
    Please Login or Register  to view this content.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Correct syntax for Gradient fill of shape

    This syntax works for me, you would need to determine the colors you wanted...

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Contributor
    Join Date
    01-02-2007
    Location
    Australia NSW
    MS-Off Ver
    2013
    Posts
    494

    Re: Correct syntax for Gradient fill of shape

    Thanks for the reply.
    Is there a way to adapt that to RGB colors?

    I have attached a dummy wkb.
    Attached Files Attached Files

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Correct syntax for Gradient fill of shape

    No, but here's a handy pallete you can use to quickly spot the colorindex number for your desired color.

    http://screencast.com/t/gyBGadXz

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Correct syntax for Gradient fill of shape

    If you manually set your default shape to have a gradient fill then the following will work. It appears the object model is broken in as much as setting TwoColorGradient does not alter the Solid setting and makes calls to gradientstop properties fail.

    Please Login or Register  to view this content.
    you can set RGB directly
    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  6. #6
    Forum Contributor
    Join Date
    01-02-2007
    Location
    Australia NSW
    MS-Off Ver
    2013
    Posts
    494

    Re: Correct syntax for Gradient fill of shape

    Thanks for replying Andy.
    I will give that code a go on Tues, and will post a reply.

    I have had a slight issue with placing a xxx,xxx,xxx RGB set of numbers including comas in a cell, and instead of hard coding the RGB, referencing the cell with xxx,xxx,xxx value in it.
    The result is not exactly to color expected for some reason.
    Will have a play with it next week anyhow....

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Correct syntax for Gradient fill of shape

    I'd split those RGB values out to separate cells if you're going to control it from the worksheet like that.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Gradient fill across multiple cells
    By dforte in forum Excel General
    Replies: 2
    Last Post: 01-18-2016, 01:20 AM
  2. Bar Graph specifying Gradient fill colors
    By coreytroy in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 03-18-2013, 08:39 PM
  3. Gradient fill a point with 2 general colors (excel 2010)
    By spacely in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-16-2012, 05:05 PM
  4. Copy SeriesCollection fill to a Shape fill
    By Serpiente in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-27-2012, 02:48 PM
  5. Custom Function for Fill Gradient?
    By rvExcelNewTip in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 07-03-2007, 08:58 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1