Results 1 to 8 of 8

Changing Shapes line color using VBA

Threaded View

  1. #1
    Forum Contributor
    Join Date
    09-07-2009
    Location
    Hemet, CA
    MS-Off Ver
    Office 2007 Professional
    Posts
    111

    Changing Shapes line color using VBA

    I just can’t seem to figure this one out. I’m using Excel 2007.
    And I have 3 different Rounded Rectangle Shapes on a single worksheet named Cover Page. I’m trying to figure out how to change the line color using VBA with option buttons. Here’s what I have so far. Option button 6 refers to a macro that opens a color chart for custom selection. Any suggestion would be greatly appreciated.


        Dim wsh As Worksheet
        Dim lngColor As Long
    
        If OptionButton6 Then
            lngColor = ShowColor
            If lngColor = -1 Then
                MsgBox "You didn't select a color!", vbExclamation
                Exit Sub
            End If
        End If
    
        Comment3.Hide
    
        Application.ScreenUpdating = False
    
        With Worksheets("Cover Page").Shapes
            .Line.OutlineColor
            Select Case True
            
            Case OptionButton1.Value
                .Color = RGB(146, 208, 80)
    
            Case OptionButton2.Value
                .Color = RGB(120, 220, 255)
    
            Case OptionButton3.Value
                .Color = RGB(216, 216, 216)
    
            Case OptionButton4.Value
                .Color = RGB(255, 220, 110)
    
            Case OptionButton5.Value
                .Color = RGB(250, 100, 95)
    
            Case OptionButton6.Value
                .Color = lngColor
    
            End Select
        End With
    
        For Each wsh In Worksheets
            wsh.Protect DrawingObjects:=False, Contents:=True, Scenarios:=True, _
                        Password:="", UserInterFaceOnly:=True
    
            ActiveWorkbook.Protect Password:="", Structure:=True, Windows:=True
    
        Next wsh
        
        Application.ScreenUpdating = True
        
        'ActiveWorkbook.Save
    
    End Sub
    Last edited by ABabeNChrist; 11-23-2010 at 10:59 AM.

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