vba - Insert Table Caption VBA Word
问题描述
I am trying to insert caption in the word table, but it seems that I have no control on parameter position. I looked at documentation and Position:=wdCaptionPositionAbove should write caption on the top of the table and Position:=wdCaptionPositionBelow should write at the bottom of the table. But I always get it on the same side with bellow recorded code. When I was recording code the captions were creatied in the right position.
Selection.InsertCaption Label:="Table", TitleAutoText:="InsertCaption3", _
Title:="", Position:=wdCaptionPositionAbove, ExcludeLabel:=0
Selection.InsertCaption Label:="Table", TitleAutoText:="InsertCaption4", _
Title:="", Position:=wdCaptionPositionBelow, ExcludeLabel:=0
I notice that caption will be written above if I manually create one caption and set it to above. But then I can't create caption bellow except if I manually create one caption bellow.
How can I set the position of the Caption (Bellow/Above the table) with VBA.
解决方案
The MS help page on InsertCaption uses a specific Table range so it may be that your range does not correspond to a Table? To see the MS Help page for InsertCaption put the Cursor on 'InsertCaption in the VBA IDE and press F1.
Thus I'd suggest you try
Selection.Tables(1).Range.InsertCaption
推荐阅读
- r - 旧 OpenGL 1 中的近似 PBR
- python - 类中的函数在没有返回语句的情况下返回 None
- pascal - 获取一天内记录的最低度数
- python - AttributeError:“NoneType”对象没有属性“create_favorite”
- git - 很难从 Github 克隆一个 repo
- pandas - Pandas,如果列的值小于该变量,则用变量(负)替换列的值,否则保持原样
- c++ - 如何避免没有谓词的虚假唤醒?
- android - Livedata 和 ViewModel 更新无限次
- javascript - contentEditable 默认模板新行
- loops - 如何在 Shopify 液体中合并两个集合而不将其更改为数组?