Refresh OLE Objects

tonykslee

New Member
Joined
Apr 25, 2014
Messages
8
Hey guys,

I have 2 subs. One sub that deletes all OLE SpinButtons, and one that Creates them.
If i run these two subs separately then it works just fine, but when i call both of them within a third sub, it freaks out and creates the buttons all out of order and linked to the wrong cells.

Here is the skeleton of my code:
Code:
'deletes and creates all spinners
Sub refreshSpinners()
    Application.ScreenUpdating = False
    deleteAllSpinners
    createAllSpinners
    Application.ScreenUpdating = True
End Sub


'clear all spin code - test code
Sub deleteAllSpinners()
    For counter1 = 1 To Worksheets("Profiles").Cells(totalProjectsY, totalProjectsX)
        deleteSpinCode (counter3)
        deleteSpinButton (counter1)
    Next
End Sub


'create all spin buttons test code
Sub createAllSpinners()
    For counter1 = 5 To Worksheets("Profiles").Cells(totalProjectsY, totalProjectsX) + 4
        addSpinCode (counter2 - 4)
        createSpinButtons (counter2)
    Next
End Sub

Also posted question in:
ExcelForum: http://www.excelforum.com/excel-programming-vba-macros/1006817-refresh-ole-objects.html
OzGrid: http://www.ozgrid.com/forum/showthread.php?t=187898&p=711299#post711299
 
Last edited:

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Try putting Option Explicit as the first line of the code module.
 
Upvote 0
Where is counter1 declared?

Where are counter2 and counter3 declared and initialized?
 
Upvote 0
Where is counter1 declared?

Where are counter2 and counter3 declared and initialized?

Sorry about that,

counter 1, 2 and 3 are fields that are declared as integers at the top. I use the same counter names throughout my code
 
Upvote 0
Lacking the big picture, what happens when you step through the code?
 
Upvote 0
So basically, there's a button that adds a 'project'.
This project has a field that i have a spinner button attached to it.

When i add/delete a project, i don't want a spinner button to be there if there is no project. and i don't want a project to be there without a spinner.
i hope that clears it up a bit..
 
Upvote 0
I re-coded it to just toggle visibility!
This works great!

Though the issues with the out of order spinners wasn't solved, i'm gonna mark this as solved just because an alternate solution was found!

Thanks a lot!
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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