vb6 - Link ActiveX to Excel -
hope can help!
i programming in vb6 , trying write activex control indicator. indicator should change color relative excel open workbook cell being true or false. indicator should auto updating i.e. indicator needs link live excel cell.
i can place several of indicators c/w links different cells on userform. workbook opened , tested in userform , object references set ok.
i can't figure out how link indicator excel cell.
this part of larger project trying. other control such bargraphs, switches etc. added if can first 1 working.
thanks in advance
you need first add reference microsoft excel x.x library in control's references.
next, should add private module level variable of type excel.worksheet, , declare withevents, e.g.
private withevents m_oworksheet excel.worksheet
you should create property set procedure called worksheet sets variable.
then should add code change event, e.g.
private sub m_oworksheet_change(byval target range) if target.column = 1 , target.row = 2 ' m_oworksheet.range("a2") 'do coding here end if end sub
obviously, .column = 1 , .row = 2 replaced cell coordinates interested in. used coordinates "a2", found objects returned m_oworksheet.range("a2") cannot directly compared target object, e.g.
if target m_oworksheet.range("a2")
i tried extract cell reference "a2" target, can't seem find way it, unless write function conversion of column/row string reference.
note previous answer provided very wrong, since testing
if target = m_oworksheet.range("a2)
... worked because default value properties identical. fall on if changed cell had same value "watched" cell.
Comments
Post a Comment