Hide shapes (buttons) before printing

K

Ken Loomis

So I now have shapes that acts as buttons on my worksheet thanks to help I
got from this group.

Now I want to hide those shapes before I print out the report. So I plan to
add a macro, called from yet another button, to do a print preview.

I'd like to hide those buttons before I do the print preview and then unhide
them at the end of that macro.

From what I am begining to understand about the Exel object model, I suspect
there is a collection of shapes on the workseeht and that each shape in that
collection has a 'visible' property. Since all od the shaps on this
worksheet are button, I will want to hide all of them. And, I may even get
button happy and add more shapes.

So my question is:

How do I hide/unhide all the shapes on a worksheet?

Thanks,
Ken Loomis
 
K

kkknie

You pretty much have it already. Here's the code:

Sub test()
Dim s As Shape
For Each s In ActiveSheet.Shapes
s.Visible = msoFalse
Next
End Sub

Use msoTrue to set them back to visible.
 
G

Geof Wyght

Won't the PrintObject property of the button do? Set it to
False. An educated guess.
Geof.
 
T

Tom Ogilvy

To expand on Geof's suggestion, right click on the shape and select Format
AutoShape. Go the properties tab and unselect Print Object.

Or you can run this one time

Sub Tester2()
Dim shp As Shape
For Each shp In ActiveSheet.Shapes
On Error Resume Next
shp.ControlFormat.PrintObject = False
On Error GoTo 0
Next
End Sub
 
K

Ken Loomis

I discovered that after I posted. And yes, I can set that manually from the
worksheet using the Format Autoshape & Properties tab.

That is neat beacuse it always shows the shapes but never prints them.

Thanks for the help.
 
K

Ken Loomis

Thanks, Tom.

That sub will help since I am still adding buttons to this worksheet and
won't need to individually set that as I go. Just run it at the end when I
am done.

Ken Loomis
 
Joined
Mar 2, 2011
Messages
1
Reaction score
0
Hi,

I would like to ask if how can i hide all the shapes/button in the workbook, wherein the workbook have 8 worksheets and some of the worksheets have buttons/shapes needed to be hidden.

Please help. Thanks.

Or please can someone developed this code I have made. Make it simple.
If cmdNo = "ON" Then
Sheets(1).Activate
Sheets(1).Buttons.Visible = True
Sheets(3).Buttons.Visible = True
Sheets(5).Buttons.Visible = True
Sheets(7).Buttons.Visible = True
Else
Sheets(1).Activate
Sheets(1).Buttons.Visible = False
Sheets(3).Buttons.Visible = False
Sheets(5).Buttons.Visible = False
Sheets(7).Buttons.Visible = False
End If
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Shape Arrays VBA 0
Identify Shapes 4
Grouping Shapes in 2007 3
Shapes Fill 2
Detecting selection before click 4
Shapes in 2010 1
Hide/Show Shapes on Worksheet?? 2
searching for shapes 8

Top