If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Line Weight

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-29-09, 11:18
campster campster is offline
Registered User
 
Join Date: Feb 2005
Posts: 332
Line Weight

The code below works in Excel 2007 but not in 2003.
Does anyone know the equivalent code in 2003 to chnage the weight of a line?

Code:
 
For Each oXLChart In oXLBookCurrent.Charts
    For Each oXLSer In oXLChart.SeriesCollection
      
      If Not sWeight = "" Then
        oXLSer.Format.Line.Weight = sWeight
      End If
      
    Next
  Next
Reply With Quote
  #2 (permalink)  
Old 07-29-09, 12:13
weejas weejas is offline
Registered User
 
Join Date: Sep 2006
Location: Surrey, UK
Posts: 448
The easiest way to find the code that you need is to record a macro doing that action. Then you just look at the code that the macro recorder generates, and ignore the bits that you don't need.
__________________
10% of magic is knowing something that no-one else does. The rest is misdirection.
Reply With Quote
  #3 (permalink)  
Old 07-29-09, 12:52
campster campster is offline
Registered User
 
Join Date: Feb 2005
Posts: 332
The problem is that the line weight method has to belong to the seriesCollection object. I'm not sure that you can duplicate that from a macro.
Reply With Quote
  #4 (permalink)  
Old 07-29-09, 13:24
campster campster is offline
Registered User
 
Join Date: Feb 2005
Posts: 332
I tried weejas suggestion and built the following macro by selecting a series and setting it's width to a thick line.

Code:
 
    ActiveChart.SeriesCollection(1).Select
    With Selection.Border
        .ColorIndex = 57
        .Weight = xlThick
        .LineStyle = xlContinuous
    End With
    With Selection
        .MarkerBackgroundColorIndex = xlNone
        .MarkerForegroundColorIndex = xlNone
        .MarkerStyle = xlNone
        .Smooth = False
        .MarkerSize = 3
        .Shadow = False
    End With
It took me awhile to realize that the line properties are contained inthe border object. After realizing that I change the code to the following and it appears to work.

Code:
 
      If Not sWeight = "" Then
        If Application.Version > 11 Then
           oXLSer.Format.Line.Weight = sWeight
        Else
          If sWeight > 4 Then
            sWeight = 4
            oXLSheetControl.Cells(20, 4).Value = 4
            MsgBox "Line weight cannot exceed 4." & vbCrLf & _
                   "Setting weight to max value.", _
                    vbOKOnly, _
                    "Line weight limit exceeded"
          End If
          oXLSer.Border.Weight = sWeight
        End If
      End If
Thanks for the suggestion weejas
Reply With Quote
  #5 (permalink)  
Old 07-30-09, 06:16
weejas weejas is offline
Registered User
 
Join Date: Sep 2006
Location: Surrey, UK
Posts: 448
You're welcome!

That piece of advice was the single most useful thing that I learned on a VBA course in 2005.
__________________
10% of magic is knowing something that no-one else does. The rest is misdirection.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On