+ Reply to Thread
Results 1 to 3 of 3

Manipulating AcitveX controls on Worksheet

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    09-30-2009
    Location
    Barcelona
    MS-Off Ver
    Excel 2010
    Posts
    274

    Question Manipulating AcitveX controls on Worksheet

    Hi,

    I am trying to develop some drag-n-drop interface for schedules which is easy to operate and updates actual dates in a table.
    so far I managed to move an Image ActiveX control, using mouseUp and MouseDown events of the image (and copying massively from this post)

    however, I am facing difficulties even storing an ActiveX Label control into a variable
    the code below works, but if I define lb as Label, it says "Type mismatch"

    defined as "variant" it all works fine, but when I try to change the label position an error appears saying that this object does not support such property

    '2015-04-02 / B.Agullo /
    Public Sub Test()
    'description here
    
        Dim s As Image
        Dim rg As Range
        Dim lb As Variant
        Dim sX As shapeX
        Static LastTime!
        
        SHAPESws.Range("_execute") = 1
        
        Set s = SHAPESws.Image1
        Set lb = SHAPESws.OLEObjects("Label1").Object
        
        Set rg = Worksheets("ranges").Range("A1")
        
        
        Set sX = createShapeX(s:=s, lb:=lb, rg:=rg)
        
        Do
            If Timer >= LastTime! + 0.5 Then
                
            End If
            
            DoEvents
            
        Loop While SHAPESws.dragAndDropTGL
        
    End Sub
    Private Sub StartLoop()
        Dim pt As POINTAPI
        
        Do Until StopLoop
            Call GetCursorPos(pt)
            pt = ScreenPixelsToWorkSheetPoints(pt)
            
            With sh
                .Left = pt.x
                .Top = pt.y
            End With
            
            With lb
                .Left = pt.x '<---- here is when the error appears... 
                .Top = pt.y
            End With
            
            DoEvents
        Loop
    
    End Sub
    feel free to try the same file I am working on superShape.xlsm

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Manipulating AcitveX controls on Worksheet

    Hi bagullo,

    Try the following
    Public Sub TestActiveXLabel()
        
        Dim lbOne As msforms.Label
        Dim lbTwo As OLEObject
        
        Set lbOne = ActiveSheet.OLEObjects("Label1").Object
        Set lbTwo = ActiveSheet.OLEObjects("Label1")
        
        Debug.Print lbOne.Caption
        Debug.Print lbTwo.Object.Caption
            
        'The following line generates a runtime error
        Set lbTwo = ActiveSheet.OLEObjects("Label1").Object
    
    End Sub
    Lewis

  3. #3
    Forum Contributor
    Join Date
    09-30-2009
    Location
    Barcelona
    MS-Off Ver
    Excel 2010
    Posts
    274

    Re: Manipulating AcitveX controls on Worksheet

    Hi Lewis,
    thanks for your feedback --
    indeed using msforms.label solved the 'type mismatch' error
    however, I am not quite satisfied with the performance to drag and drop boxes...
    but I will post that as a different thread!

    thank you!

+ 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. Manipulating Grouping controls with VBA
    By sportsguy in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-23-2013, 01:33 PM
  2. Manipulating two recordset in one worksheet
    By gamaz in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-16-2009, 05:52 PM
  3. Manipulating Excel Worksheet Embedded into Document
    By jasoncw in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 04-09-2008, 02:43 PM
  4. [SOLVED] Manipulating Controls on a worksheet
    By David Looney in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-26-2006, 03:10 PM
  5. creating/manipulating form controls placed on a spreadsheet in excel using vba
    By jeff.naifeh@gmail.com in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-14-2005, 10:05 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