+ Reply to Thread
Results 1 to 6 of 6

Hiding a ScrollBar

Hybrid View

  1. #1
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Hiding a ScrollBar

    Hi all,

    I am trying to fine tune a charting tool but Excel is acting odd, or I am odd, or both . Whatever the case may be, if you fill the charts with data using the buttons, click the top chart to zoom the view size, use the scroll bar, and then click the top chart again to zoom the view size back to 75, the scroll bar will not hide (unless you click the chart again, and then again).
    Within the module ChartClick, I have the following code:
    Dim scrBar1 As Shape, scrBar2 As Shape
    Set scrBar1 = ActiveSheet.Shapes("ScrollBar1")
    Set scrBar2 = ActiveSheet.Shapes("ScrollBar2")
    '---The first if statement expands the view size---'
        If ActiveWindow.Zoom = 75 And ActiveWindow.Zoom < 100 Then
            Application.DisplayFullScreen = True
            ActiveWindow.Zoom = 100
            Application.Goto Sheets("Sheet2").Range("A3"), True
            HideCansim
            scrBar1.Visible = msoFalse
            scrBar2.Visible = msoTrue
            RadioButton_Explode
            Help_Explode
            With Range("M12:M16")
                .Font.ColorIndex = 0
                .Font.Size = 14
            End With
            Range("G12").Select
            Exit Sub
        End If
    '---The next if statement zoom the viewsize back to 75---'
        If ActiveWindow.Zoom = 100 Then
            Application.DisplayFullScreen = False
            ActiveWindow.Zoom = 75
            Application.Goto Sheets("Sheet2").Range("A1"), True
            UnHideCansim
            scrBar1.Visible = msoTrue
            scrBar2.Visible = msoFalse
            RadioButton_Implode
            Help_Implode
            Range("M12:M16").Font.ColorIndex = 2
            Range("G12").Select
            Exit Sub
        End If
    Does something here look off? Perhaps, while I am thinking about it, is it a sequential code reading issue? I don't know but if someone has an idea, I would love to here it! Thanks so much
    Attached Files Attached Files
    Last edited by Mordred; 02-23-2011 at 12:59 PM.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  2. #2
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Hiding a ScrollBar

    Well, its has nothing to do with sequential code reading.

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

    Re: Hiding a ScrollBar

    Try adding a DoEvents line after chaning the visible properties of the scrollbars.

            HideCansim
            scrBar1.Visible = msoFalse
            scrBar2.Visible = msoTrue
    DoEvents
            RadioButton_Explode
    Cheers
    Andy
    www.andypope.info

  4. #4
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Hiding a ScrollBar

    Thanks Andy, but no changes.

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

    Re: Hiding a ScrollBar

    My bad, I did not actually use the scroller to adjust the chart before zooming out. When I did I could replicate the problem.

    Try this instead.
    Sub Chart1_Click()
        
        Application.ScreenUpdating = False
        Dim scrBar1 As Shape, scrBar2 As Shape
        
        Set scrBar1 = ActiveSheet.Shapes("ScrollBar1")
        Set scrBar2 = ActiveSheet.Shapes("ScrollBar2")
        If ActiveWindow.Zoom = 75 And ActiveWindow.Zoom < 100 Then
            Application.Goto Sheets("Sheet2").Range("A3"), True
            
            Application.DisplayFullScreen = True
            ActiveWindow.Zoom = 100
            HideCansim
            scrBar1.OLEFormat.Object.Visible = False
            scrBar2.OLEFormat.Object.Visible = True
            RadioButton_Explode
            Help_Explode
            With Range("M12:M16")
                .Font.ColorIndex = 0
                .Font.Size = 14
            End With
            Range("G12").Select
            Application.ScreenUpdating = True
            Exit Sub
        End If
        If ActiveWindow.Zoom = 100 Then
            
            Application.Goto Sheets("Sheet2").Range("A1"), True
            Application.DisplayFullScreen = False
            ActiveWindow.Zoom = 75
            UnHideCansim
            scrBar1.OLEFormat.Object.Visible = True
            scrBar2.OLEFormat.Object.Visible = False
            RadioButton_Implode
            Help_Implode
            Range("M12:M16").Font.ColorIndex = 2
            Range("G12").Select
            Application.ScreenUpdating = True
            Exit Sub
        End If
        
    End Sub

  6. #6
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Hiding a ScrollBar

    I cannot express how much I appreciate your help with this, off and on throughout the creation of this charting tool. Your suggestion worked perfectly. Thanks again.

+ 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