+ Reply to Thread
Results 1 to 2 of 2

VBA Chart - Reading and Writing MajorGridlines

  1. #1
    Registered User
    Join Date
    07-29-2008
    Location
    Canada
    Posts
    4

    Question VBA Chart - Reading and Writing MajorGridlines

    Hi I am trying to read chart properties from one chart and apply to Another.
    Everything seems to work except I can't get the linestyle of major gridlines to work. When I try to read the linestyle it give me the value of -4118 for a dashed line. Any thoughts on what I might be doing wrong? Thanks in advance. I assume the problem is with the CollectChartPropertiesFromChart() since it returns a very strange value for "ActiveChart.Axes(xlValue).MajorGridlines.Border.LineStyle "


    Dim GridlinesColour As Variant
    Dim GridlinesWeight As String
    Dim GridlinesLineStyle As String

    Sub CollectChartPropertiesFromChart()
    If ActiveChart.Axes(xlValue).HasMajorGridlines Then GridlinesColour = ActiveChart.Axes(xlValue).MajorGridlines.Border.ColorIndex
    If ActiveChart.Axes(xlValue).HasMajorGridlines Then GridlinesWeight = ActiveChart.Axes(xlValue).MajorGridlines.Border.Weight
    If ActiveChart.Axes(xlValue).HasMajorGridlines Then GridlinesLineStyle = ActiveChart.Axes(xlValue).MajorGridlines.Border.LineStyle
    End Sub

    Sub ApplyChartProperties()
    If ActiveChart.Axes(xlValue).HasMajorGridlines Then ActiveChart.Axes(xlValue).MajorGridlines.Border.ColorIndex = GridlinesColour
    If ActiveChart.Axes(xlValue).HasMajorGridlines Then ActiveChart.Axes(xlValue).MajorGridlines.Border.Weight = GridlinesWeight
    If ActiveChart.Axes(xlValue).HasMajorGridlines Then ActiveChart.Axes(xlValue).MajorGridlines.Border.LineStyle = GridlinesLineStyle
    End Sub
    Last edited by Leith Ross; 07-29-2008 at 06:18 PM. Reason: Code tags not working - OP was having problems with it

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello revector,

    As a new user, I don't expect you to be familiar with all the rules for posting just yet. The title of your post is very important. It helps others looking for the same or similar information to find answers quickly. Please be more specific about what you need. The database uses the title when searching for answers. Titles like "I need help" are not really useful when you need to get an answer to your question.Please change your title. It will help you and everyone else using the forum.

    You can read the rules and how to change your title by clicking on the link below...

    Forum Rules

    Sincerely,
    Leith Ross

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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