Making a text box non-printable with VBA - how?

Bill Hamilton

Board Regular
Joined
Mar 30, 2004
Messages
95
OK, I've written some simple code to create and insert a standard text box (not a 'control') onto a sheet using Shapes.addtextbox and I want to make it non-printable. I can't seem to find any construct to do it as none of the Shape or Shapes properties/methods seem to have anything to do with that.

I started the macro recorder and manually opened the box's Properties and unchecked Print Object but it recorded absolutely nothing. Very helpful.

Any ideas, O Mighty Coders?

(Using Excel 2007 under Win7)

Bill
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Try like this

Code:
ActiveSheet.Shapes("TextBox 1").PrintObject = msoFalse
 
Upvote 0
Hi. Thanks for the response. Doesn't work unfortunately. Here's my code (reduced to the relevant essentials):
Code:
Sub TestTextBox()
Dim wSheet As Worksheet
Dim shp As Shape
Set wSheet = ActiveSheet
Set shp = wSheet.Shapes.addtextbox(msoTextOrientationHorizontal, _
                        200, 150, 300, 300)
       shp.Name = "Help Box"
       shp.TextFrame.Characters.Text = "Text for the box"
       ActiveSheet.Shapes("Help Box").PrintObject = msoFalse
'       shp.PrintObject = msoFalse
End Sub

Both the "ActiveSheet.Shapes("Help Box").PrintObject = msoFalse" as you suggested and my alternative "shp.PrintObject = msoFalse" instructions fail with "Object doesn't support his property or method" runtime error 438.
 
Upvote 0
This worked for me

Code:
Sub TestTextBox()
Dim wSheet As Worksheet
Dim shp As Shape
Set wSheet = ActiveSheet
Set shp = wSheet.Shapes.AddTextbox(msoTextOrientationHorizontal, _
                        200, 150, 300, 300)
       shp.Name = "Help Box"
       shp.TextFrame.Characters.Text = "Text for the box"
       shp.Select
       Selection.PrintObject = False
'       shp.PrintObject = msoFalse
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,730
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top