+ Reply to Thread
Results 1 to 11 of 11

Remove white rectangle around the shapes when shown on Userform

  1. #1
    Registered User
    Join Date
    06-27-2020
    Location
    Istanbul
    MS-Off Ver
    Excel 2016 Pro Plus 32 Bit
    Posts
    10

    Remove white rectangle around the shapes when shown on Userform

    Platform: Excel 2016 Pro Plus 32 Bit on Windows 10 Pro 64 Bit

    I have a repository of some complex shapes in a worksheet, which I drew in PowerPoint using standard Shape objects. I transfer them to a UserForm from within the VBA code (by means of Andy Pope's method) controlled by a SliderBar on the form. But there are always white rectangles around the shapes touching the max width and height of them when shown on the UserForm (they don't exist when the shapes are still in the worksheet). I wonder if there is a way to remove them either in the code or when drawing? Or, can this white area be filled with a different color, say the back color of the Frame on the UserForm so that it becomes invisible?
    Last edited by Leden; 07-10-2020 at 09:14 AM.

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Remove white rectangle around the shapes when shown on Userform

    Can you provide a sample file to experiment with?
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Registered User
    Join Date
    06-27-2020
    Location
    Istanbul
    MS-Off Ver
    Excel 2016 Pro Plus 32 Bit
    Posts
    10

    Re: Remove white rectangle around the shapes when shown on Userform

    Can you tell me how to add the sample workbook in this thread not just the part of the code?
    Sorry for the inconvenience that I cause..

  4. #4
    Registered User
    Join Date
    06-27-2020
    Location
    Istanbul
    MS-Off Ver
    Excel 2016 Pro Plus 32 Bit
    Posts
    10

    Re: Remove white rectangle around the shapes when shown on Userform

    I think I've found it..

    Please click button "My Oval Shape" and/or scroll the top slider for Part shapes 1 to 7 to see my problem
    Attached Files Attached Files

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

    Re: Remove white rectangle around the shapes when shown on Userform

    As I explained in the email the white area is caused by copying a shape with transparency, which bitmap does not support.
    So to maintain the illusion the shape are place in front of a shape with a background to match that of the area it will be displayed in.
    The background is also the same size as the display area so if you use large shapes there will be gaps, which will be white.

    If you reduce the size of the oval and use this revised code it will look more like my example.

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

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

    Re: Remove white rectangle around the shapes when shown on Userform

    I have reduced the size of the shapes.

    Also there is now a method, UsePart, which copies the shape to be displayed.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    06-27-2020
    Location
    Istanbul
    MS-Off Ver
    Excel 2016 Pro Plus 32 Bit
    Posts
    10

    Re: Remove white rectangle around the shapes when shown on Userform

    Thanks a lot Andy, I'll apply your suggestions to my application to see if they work. Two remarks though:

    -If this is an inherent problem of shape transparency which bitmap does not support, what about using the metafile format instead?
    -On the other hand, I wonder if one of my shapes, say Part5 or Part6 can be parametrically drawn directly on a Userform just like an mso box/oval element that you showed in your original method? After all, my shapes mainly consist of round-cornered trapezoids which are put together in different ways. If this could be possible then it would be another classy solution to the problem.. What do you think?

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

    Re: Remove white rectangle around the shapes when shown on Userform

    Rather than using the userform draw approach why not simple load the 7 shapaes in to image controls?

    I copied the shape from the worksheet into powerpoint and then used the save picture to save each image to a gif.
    You can then use the Picture property at design time to load the gif images
    Attached Files Attached Files

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    81,288

    Re: Remove white rectangle around the shapes when shown on Userform

    Platform: Excel 2016 Pro Plus 32 Bit on Windows 10 Pro 64 Bit
    Please update your forum profile with the Excel version - your Windows version is of little practical use to us. Thanks.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  10. #10
    Registered User
    Join Date
    06-27-2020
    Location
    Istanbul
    MS-Off Ver
    Excel 2016 Pro Plus 32 Bit
    Posts
    10

    Re: Remove white rectangle around the shapes when shown on Userform

    Unfortunately this solution does not seem to work for me because in my real application color of the parts changes in the run-time over a scheme controlled by a vertical slider. There are more than 250 different colors over the full range of the slider to give a continuous color change effect..
    Therefore I can only do this by fill command when they are still in "shape mode" before converted to bitmap images.
    I may have not stated explicitly but I already have a working solution (see bottom slider in my sample file) in a way that Part's color is changed while it is in the worksheet but transferred to the Userform as a group picture (Assy) in bitmap which consists of Part & Tool. "Tool" acts like a background object to absorb the white rectangle. In other words, each Part is accompanied by its Tool and they both form the Assy (assembly). This works alright but it seems to be a clumsy solution to me. I am just trying to discover if there is a smarter and more efficient way to do the same.

  11. #11
    Registered User
    Join Date
    06-27-2020
    Location
    Istanbul
    MS-Off Ver
    Excel 2016 Pro Plus 32 Bit
    Posts
    10

    Re: Remove white rectangle around the shapes when shown on Userform

    I assume this thread is solved now after several awesome ideas from Andy Pope.
    Thank you very much all who have contributed..

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Pick rectangle from list that is larger than other rectangle and minimize area.
    By jgwentworth96 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 02-05-2020, 01:57 PM
  2. [SOLVED] how to remove right rectangle on left side of the cell
    By hktom in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-05-2015, 04:46 AM
  3. Add rectangle shapes at the beginning and end of a bar
    By savy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-13-2015, 04:06 PM
  4. [SOLVED] TextBox turns into a rectangle when using AvtiveSheet.Shapes
    By sur4j in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-06-2014, 04:35 PM
  5. [SOLVED] Detecting shapeS out of rectangle perimeters
    By Heva in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-30-2013, 05:34 AM
  6. Excel 2003 - white shapes printing black
    By LxMxFxD in forum Excel General
    Replies: 2
    Last Post: 04-07-2010, 03:17 PM
  7. [SOLVED] Formatting Auto Shapes - Rectangle
    By Woody13 in forum Excel General
    Replies: 1
    Last Post: 05-19-2005, 04:06 PM

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