Results 1 to 4 of 4

Thread: *Resolved* Hide/Show Shapes

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2004
    Location
    Right here
    Posts
    275

    Resolved *Resolved* Hide/Show Shapes

    I'm trying to write a short piece of VBA code which will first of all show a shape (to cover part of the worksheet whilst some calculations are performed) then to hide it again once the calculations are complete.

    I thought it would be easy but the code I have doesn't work. The code basically goes like this:

    Code:
    Shapes("BoxOut1, BoxOut2, BoxOut3").Visible = True
    Perform the calcuations
    Shapes("BoxOut1, BoxOut2, BoxOut3").Visible = False
    This just returns an error though.....I don't think the SHAPE function is something that VBA recognises. I also want to be able to hide/show the shapes without having to select them. I thought that Selecting the shapes first and then using WithSelection....to hide and show them again might work, but I'd rather just use a command and not select them.

    Anyone have any ideas?

    Cheers
    -Rob
    Last edited by TheRobster; Dec 14th, 2004 at 07:39 AM.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Hide/Show Shapes

    You dont need to select the shape before change its visibility property. You
    can use its index property to reference a particular shape in the shapes
    collection. VBA does recognise the Shape object. Ex from MS VBA Help:

    Code:
    Set myDocument = Worksheets(1)
    myDocument.Shapes(1).Flip msoFlipHorizontal
    myDocument.Shapes("Rectangle 1").Flip msoFlipHorizontal
    Also, try using the screenupdating method to update your
    changes on the screen during calculations or shapes being shown / hidden.
    Its like DoEvents in VB.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    May 2004
    Location
    Right here
    Posts
    275

    Re: Hide/Show Shapes

    K, I got it working.

    Cheers
    -Rob

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: *Resolved* Hide/Show Shapes

    No prob.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width