excel vba created active x button missing text until moved in design mode -


so had working in giant excel project until today. have large project of code i'm running on multitude of sheets within large group of workbooks. part of code makes buttons needed. edited unrelated range formats sheets , when ran code, 1 of 3 button creation processes created buttons appear have no caption. however, when enter design mode , move buttons, text appears (i trying @ properties when found out). of buttons have valid values caption, none of them being displayed until manually moved , moved back. considering there ~ 10,000 of these buttons between workbooks, problematic manual process. (luckily haven't run code on workbooks yet)

i can't life of me figure out why these buttons having happen, consistent behavior. other active x buttons not having same problem.

here code active x button works:

sub addnamebutton(tc range, sht worksheet)     dim newbutton oleobject     dim buttonexist boolean     dim buttonname string     buttonexist = false     buttonname = sht.name & tc.row & "name"     sht        on error resume next         buttonname = sht.oleobjects(buttonname)         if buttonname <> ""             buttonexist = true         else             buttonexist = false         end if         if buttonexist = true             sht.oleobjects(buttonname).delete             goto createbutton             on error goto 0         else             goto createbutton             on error goto 0         end if     end  createbutton:     tc.cells(1, 6)                 set newbutton = sht.oleobjects.add _                     (classtype:="forms.commandbutton.1", _                     link:=false, displayasicon:=false, _                     left:=.left, _                     top:=.top, _                     height:=.height, _                     width:=.width)                 newbutton.object.caption = "name"                 newbutton.object.font.size = 9                 newbutton.object.font.bold = true                 newbutton.name = sht.name & .row & "name"                 newbutton.object.font.name = "arial"                 newbutton.placement = xlmoveandsize     end end sub 

and here code of problematic button:

sub addappbutton(tc range, sht worksheet)     dim newbutton oleobject     dim buttonexist boolean     dim buttonname string     buttonexist = false     buttonname = sht.name & tc.row & "app"     sht         on error resume next         buttonname = sht.oleobjects(buttonname)         if buttonname <> ""             buttonexist = true         else             buttonexist = false         end if         if buttonexist = true             sht.oleobjects(buttonname).delete             goto createbutton             on error goto 0         else             goto createbutton             on error goto 0         end if     end  createbutton:         tc.cells(1, 8)                 set newbutton = sht.oleobjects.add _                     (classtype:="forms.commandbutton.1", _                     link:=false, displayasicon:=false, _                     left:=.left, _                     top:=.top, _                     height:=.height, _                     width:=.width)                 newbutton.object.caption = "app"                 newbutton.object.font.size = 9                 newbutton.object.font.bold = true                 newbutton.name = sht.name & .row & "app"                 newbutton.object.font.name = "arial"                 newbutton.placement = xlmoveandsize         end end sub 

in code calls these, called right next each other:

call module3.addappbutton(tc, sht) call module3.addnamebutton(tc, sht) 

that's part of 6 different button creation calls (2 before them , 2 after) , of other 4 active x buttons working fine. app button having problem. i've tried few things now, changing buttons default location on worksheet, editing button's formatting after final sheet formatting, etc. nothing has worked. cannot life of me figure out difference between 2 processes posted (other name), , can't figure out why value of caption on button, not being displayed on button until button moved on sheet.

before recommends not working active x buttons, have other form types , of oleobject types need maintained type when other processes run, can manipulate of like-typed of objects (all oleobjects same context while other form types have other contexts). it's more complicated "don't work active x buttons!" them being active x buttons serving specific purpose.

copying code i'm posting new worksheet results in buttons not broken, assume there's else weird going on, i'm posting hoping has run similar , might able figure out what's breaking in document display (it seem display issue, albeit 1 cripples excel app).

thanks help!

this turns out not code related, instead issue when creating button on sheet hidden rows/columns. may not simple that, able resolve putting sht.rows.hidden = false , sht.columns.hidden = false before createbutton code. resolved issue entirely.

i suspect there sort of issue within excel , addressing point offset properties "top" , "left" when being referenced in relation (after, touching, something) hidden rows/columns. i'd dig more figure out why happens, i've got other work do.


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -