+ Reply to Thread
Results 1 to 4 of 4

Shapes vs oleobjects vs oleobject.object ( for commandbutton properties )

  1. #1
    Registered User
    Join Date
    11-22-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    2

    Question Shapes vs oleobjects vs oleobject.object ( for commandbutton properties )

    Hi,

    1. Can someone please explain why for a commandbutton in VBA for Excel 2010 (and other versions maybe) I can change its properties through Worksheets(1).Shapes(1).Top (or .Left, .Width, .Height) but I cannot change the font size. I tried Worksheets(1).Shapes(1).Font.Size, or Worksheets(1).Shapes(1).TextEffect.FontSize, or Worksheets(1).Shapes(1).TextFrame.Characters.Font.Size, but was always getting run-time errors.

    2. I was getting desperate but found that I could access the commandbutton properties through the OLEObjects collection. I found an example on the web showing that I could set the dimension properties with: Worksheets(1).OLEObjects(1).Top (or .Left, .Width, .Height). But what bugs me is that the Font size property can only be accessed through Worksheets(1).OLEObjects(1).Object.Font.Size. So why through the Object property of the OLEObject and not through the OLEOBject directly like for the dimension/placing properties?? I don't get it !


    3. As stupid as this might sound to an expert, I went back and tried Worksheets(1).Shapes(1).Object.Font.Size. I did not expect that to work but wanted to check just to understand better that I was effectively dealing with 2 different concepts, and it effectively didn't work.

    Thanks so much for helping out!

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Shapes vs oleobjects vs oleobject.object ( for commandbutton properties )

    Hello Xeliax,

    Welcome to the Forum!

    Hopefully I can explain this and it makes sense. First, let's look at a Shape object. Shapes belong to and are drawn by Excel application. Shapes are really limited in their ability to interact with the user. They can be clicked and execute hyperlinks.

    To provide users with more interaction, there are objects that belong to the OLE (Object Linking and Embedding) or ActiveX class. These objects are generally controls that have specific functions and distinct shapes. The OLE objects are basically templates for other control objects. This why an OLE object has an Object property. The OLE object is the template containing features common to all controls like height, fore color, font, etc., and the Object property applies to the specific control itself.

    Remember I said that the Shape object could contain a hyperlink? Objects that can contain information about other objects and interact with them are known as "Container Objects". Some other container objects are UserForms, Frames, and Browser control objects. If the Shape is an ActiveX (OLE) control, Excel draws the outline of the control and provides an internal link to the OLE object. The OLE object, in turn, provides the basoic control template and an Object property that points to the actual control object class., providing access the Object's properties, methods, and events.

    Hope this makes it a little clearer for you.
    Last edited by Leith Ross; 11-22-2013 at 11:09 PM.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    11-22-2013
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Shapes vs oleobjects vs oleobject.object ( for commandbutton properties )

    Great answer! Thank you so much!
    Now I understand much of the concepts.
    I wished Microsoft would have made all this info available in Excel Help under "commandbutton"! Lol!

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Shapes vs oleobjects vs oleobject.object ( for commandbutton properties )

    Hello Xeliax,

    You're welcome. I stopped making my "wish list" for Microsoft awhile ago after it went from a sheet to a book to an encyclopedia.

+ 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. What is the difference between DIM as Object and DIM as OLEObject?
    By brharrii in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-26-2013, 01:28 PM
  2. Properties for auto shapes
    By zplugger in forum Excel General
    Replies: 3
    Last Post: 12-17-2011, 11:50 AM
  3. Commandbutton created as OLEObject becomes Forms button ?!
    By andreco in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-25-2009, 10:08 PM
  4. Avoid changes of text properties when calling Shapes().Formula
    By EseKuent in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-04-2009, 02:31 AM
  5. [SOLVED] Error on fetching object in OLEObject
    By syrhus in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-02-2005, 12:06 PM

Tags for this Thread

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