+ Reply to Thread
Results 1 to 5 of 5

Can't use variable to refer to ActiveX Images

  1. #1
    Forum Contributor
    Join Date
    07-01-2018
    Location
    Adelaide, South Australia
    MS-Off Ver
    Office 365, & Excel 2016 on windows 10, & 14.7 for mac, & Excel 2015 for mac
    Posts
    173

    Can't use variable to refer to ActiveX Images

    On my worksheet I have two ActiveX image objects. This allows me to store images in the sheet, and to pass them to a powerpoint presentation in later processes.

    The problem is that I am only able to reference the images explicitly. IE I have to hard code using the name of the object like
    Please Login or Register  to view this content.
    I have been completely unable to set a variable to the image and perform operations with it. I want to be able to pass the name of an object and have the code work with that

    What I want would be something like
    Please Login or Register  to view this content.
    Any help in clarifying this would be great. If I have to hard code, it'll be a real pain when I have to have more than 2 images
    If my solution helped, please consider adding Rep

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Can't use variable to refer to ActiveX Images

    Try something like this...

    Please Login or Register  to view this content.
    Last edited by AlphaFrog; 01-11-2021 at 04:53 AM.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Contributor
    Join Date
    07-01-2018
    Location
    Adelaide, South Australia
    MS-Off Ver
    Office 365, & Excel 2016 on windows 10, & 14.7 for mac, & Excel 2015 for mac
    Posts
    173

    Re: Can't use variable to refer to ActiveX Images

    Quote Originally Posted by AlphaFrog View Post
    Try something like this...

    Please Login or Register  to view this content.
    Sorry for the delay in getting back to this. I just became a father earlier than expected.

    You code gives an error because .picture is not a property of a shape object.

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Can't use variable to refer to ActiveX Images

    Congratulations on the kid. Good call on taking care of that first. You passed the first test.

    Try something like...

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    07-01-2018
    Location
    Adelaide, South Australia
    MS-Off Ver
    Office 365, & Excel 2016 on windows 10, & 14.7 for mac, & Excel 2015 for mac
    Posts
    173

    Re: Can't use variable to refer to ActiveX Images

    I was reading the vba references, and I found this. The name of the shape, and the CODENAME are not the same thing. Some references use the SHAPE NAME. Others the CODENAME.


    “You use the code name of a control in the names of its event procedures. However, when you return a control from the Shapes or OLEObjects collection for a sheet, you must use the shape name, not the code name, to refer to the control by name.
    For example, assume that you add a check box to a sheet and that both the default shape name and the default code name are CheckBox1.
    If you then change the control code name by typing chkFinished next to (Name) in the Properties window, you must use chkFinished in event procedures names, but you still have to use CheckBox1 to return the control from the Shapes or OLEObject collection”
    https://docs.microsoft.com/en-us/off...cel.oleobjects


    This explains everything that I had wrong. I was simply calling the wrong name.

+ 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. [SOLVED] Refer to ChartObject using variable?
    By franklin_m in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-19-2017, 07:21 AM
  2. ActiveX change object images
    By c.davidson in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-05-2016, 10:54 AM
  3. [SOLVED] Can I refer to a variable name stored in another variable?
    By JasperD in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-22-2015, 08:51 AM
  4. Replies: 3
    Last Post: 02-12-2015, 11:42 AM
  5. [SOLVED] refer an activex textbox
    By pankajy18 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-04-2013, 01:24 PM
  6. How to refer to array variable in vba?
    By elcentro3m in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-06-2007, 02:21 PM
  7. [SOLVED] Using a variable to refer a cell
    By jeam in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-13-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