ControlFormat.Enabled属性引发错误

时间:2019-06-14 10:42:35

标签: excel vba exception dropdown

我想锁定VBA中的动态下拉菜单,但是在尝试设置Dropdown.ControlFormat.Enabled属性时遇到问题。

ddlIsNegative.TopLeftCell.Locked = True
Set lbcf = ddlIsNegative.ControlFormat
If (lbcf.value = 2) Then
    ddlIsNegative.ControlFormat.Enabled = False
End If

设置ddlIsNegative.ControlFormat.Enabled属性时,它将引发错误

  

无法设置组对象类的启用属性

1 个答案:

答案 0 :(得分:0)

我可以通过添加其他例外来解决此问题。

//First select the items
const items = document.querySelectorAll('div#list > .listing-item');
//Next, transform this to an array using `from`, then compare
//using `sort`, finally iterate over the sorted array using `forEach`,
//and append element in the sorted array to the `#list`.
//
Array
  .from(items)
  .sort((x,y) => {
    const valueX = x.dataset.listingTitle;
    const valueY = y.dataset.listingTitle;

    if(valueX > valueY) return 1;
    else if(valueX < valueY) return -1;
    else return 0;
  })
  .forEach(element => document.getElementById('list').appendChild(element));