Problem with Shapes in VBA -- Fill is visible?

shawleigh17

Board Regular
Joined
Nov 16, 2007
Messages
79
hello,
I am trying to create a shape that covers a merged cell. This shape should have no fill, so that people can see the contents of the merged cell. Everytime I try to do this, the fill.visible = msoFalse does not seem to work, the white label is still on top of my merged cells. It seemed to work for a little while, but now the label is always filled. I had this problem before, too, when trying to create a label with a text box (the text box would never show), which is why I tried the "no fill" option. Here is the code:

Code:
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 1680#, 594#, 120#, 74.25). _
        Select
    Selection.Name = "Upload_Layout"
    ActiveSheet.Shapes("Upload_Layout").Select
    Selection.ShapeRange.Fill.Visible = msoFalse
    Selection.ShapeRange.Fill.Solid
    Selection.ShapeRange.Fill.Transparency = 0#
    Selection.ShapeRange.Line.Weight = 0.75
    Selection.ShapeRange.Line.DashStyle = msoLineSolid
    Selection.ShapeRange.Line.Style = msoLineSingle
    Selection.ShapeRange.Line.Transparency = 0#
    Selection.ShapeRange.Line.Visible = msoTrue
    Selection.ShapeRange.Line.ForeColor.SchemeColor = 64
    Selection.ShapeRange.Line.BackColor.RGB = RGB(255, 255, 255)
    Range("BB25").Select
    ActiveSheet.Shapes("Upload_Layout").Select
    Selection.ShapeRange.Fill.Visible = msoFalse
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Is it possible you already have a shape called "Upload_Layout" on the sheet? If so, you would be setting the properties for the wrong shape in your code. Try using:
Code:
   Dim shpTemp As Shape
   On Error Resume Next
   ActiveSheet.Shapes("Upload_Layout").Delete
   On Error GoTo 0
   Set shpTemp = ActiveSheet.Shapes.AddShape(msoShapeRectangle, 1680#, 594#, 120#, 74.25)
   With shpTemp
      .Name = "Upload_Layout"
      With .Fill
         .Visible = msoFalse
         .Solid
         .Transparency = 1#
      End With
      With .Line
         .Weight = 0.75
         .DashStyle = msoLineSolid
         .Style = msoLineSingle
         .Transparency = 0#
         .Visible = msoTrue
         .ForeColor.SchemeColor = 64
         .BackColor.RGB = RGB(255, 255, 255)
      End With
   End With
 
Upvote 0
Well, I tried that route, and I ended up getting a "Permission Denied" error when trying to name the shape. Any idea why this might be happening?
 
Upvote 0
Alright, I somehow fixed the problem, and now it is working perfectly. Thank you very much for your suggestion.

-Shawna
 
Upvote 0

Forum statistics

Threads
1,216,134
Messages
6,129,070
Members
449,485
Latest member
greggy

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