Excel VBA - 将参数传递给属性

时间:2015-08-13 11:35:01

标签: excel vba excel-vba

在Excel VBA中,我试图将参数值传递给属性' VerticalAlignment'。我得到的错误是:"无法设置Range类"的Horizo​​ntalAlignment属性。很明显,问题出在' horzAlign' &安培; ' vertAlign'然而,价值观是什么?

  <style>
    html {
      font: 500 16px/1.5 'Avenir Lt Std';
      box-sizing: border-box;
    }
    
    *,
    *:before,
    *:after {
      box-sizing: inherit;
    }
    
    body {
      height: 101vh;
      width: 100vw;
      background: #111;
      color: #DDD;
    }
    
    main {
      display: flex;
      flex-flow: row wrap;
      justify-content: center;
      align-items: center;
      align-content: center;
      height: 101%;
      width: 100%;
    }
    
    .center {
      display: flex;
      flex-flow: column wrap;
      justify-content: center;
      align-items: center;
      align-content: center;
      self-align: center;
      border: 3px double white;
      flex 0 0 100%;
      margin: 50% auto;
    }
    
    .center > * {
      flex: 1 1 100%;
    }
    
    .frame {
      border-bottom: 2px solid yellow;
      background: #222;
      margin: 0;
      width: -moz-min-content;
      width: -webkit-min-content;
      width: min-content;
    }
    
    .title {
      font-size: 2rem;
      font-weight: bolder;
      border: 1px solid brown;
      padding: 1px;
      font-variant: small-caps;
      margin: 0 auto;
    }
    
    .desc {
      font-size: 1.5rem;
      border: 1px solid grey;
      padding: 3px 1px;
      text-align: center;
      margin: 0 auto;
    }
    
    .caption {
      text-align: center;
      font-size: 1.2rem;
    }
    
    img {
      display: table;
      border: 1px solid yellow;
    }

  </style>
  

这是在另一个程序中调用的:

  <main>
    <figure class="center frame"> <img src="http://placehold.it/569x166/000/fff.png&text=This+is+the+Picture"
      alt="icon" style="width:596px;height:166px;" />
      <figcaption class="caption">
        <h3 class="title">This is the Title</h3>
        <p class="desc">This is the description.</p>
      </figcaption>
    </figure>
  </main>
</body>

</html>

    

3 个答案:

答案 0 :(得分:7)

查看VBA帮助值不能是"xlLeft", "xlBottom"而是xlLeft, xlBottom,即没有引号 - 它们是整数常量。

答案 1 :(得分:0)

RTFM。来自帮助:

  

此属性的值可以设置为以下之一   常量:

     

xlBottom xlCenter xlDistributed xlJustify xlTop

答案 2 :(得分:0)

根据msdn,属性值必须是以下之一:

水平:

  • xlCenter
  • xlDistributed
  • xlJustify
  • xlLeft
  • xlRight

垂直:

  • xlBottom
  • xlCenter
  • xlDistributed
  • xlJustify
  • xlTop