Change Custom Colors in MS Access using VBA

痞子三分冷 提交于 2019-12-13 19:45:15

问题


I m trying to change the color theme in access and for all the charts (bar,pie,margins,area etc) i want to add new color scheme . I m using Ms Access 2000 ,i figured a way to change each color manually by clicking on the graph and then tools-->options -->Color-->chart fills but2 problems with this approach:

1.Limits the number of colors to 8
2.I need to manually change for each graph i have over 100 graphs

any help is appreciated


回答1:


I once edited the colors of columns in charts programmatically. I am not sure anymore for which version of access though. It doesnt work anymore in access2003, so it's probably working in access 2000.

Lets say your chart is called "OLEObject".

You can edit the background like this:

    Me.OLEObject.Object.ActiveChart.PlotArea.Fill.OneColorGradient Style:=msoGradientHorizontal, Variant:=2, Degree:=0.8

to edit the color, text etc of your columns/pie you can access the seriescollection.

   With Me.OLEObject.Object.ActiveChart.SeriesCollection(i)
       .Name = "name"
       .Values = "={" & 10 & "}"
       .Interior.color = 2
       .ApplyDataLabels ShowSeriesName:=True

       With .DataLabels

           .Font.Size = 10 
           .Orientation = xlUpward
       End With

       With .Fill
            .OneColorGradient Style:=msoGradientHorizontal, Variant:=1, Degree:=0.4
            .ForeColor.SchemeColor = 3
       End With

   End With

You can add/delete columns programmatically too:

      .SeriesCollection(3).delete

      .SeriesCollection.NewSeries


来源:https://stackoverflow.com/questions/7476626/change-custom-colors-in-ms-access-using-vba

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!