79802018

Date: 2025-10-27 16:02:55
Score: 0.5
Natty:
Report link

After a bit of a pause on this issue, I managed to create another macro that inserts the non-breaking space into a caption that is placed below a table. This would typically be used for Figures that according to ISO/IEC rules have their caption below the figure, whereas for a Table it is placed above.

    ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=2, NumColumns:= _
        4, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
        wdAutoFitFixed
    With Selection.Tables(1)
        ...
        ...
    End With

    Selection.InsertCaption Label:=wdCaptionFigure, Title:=" " + ChrW(8212) + " My figute title", Position:=wdCaptionPositionBelow, ExcludeLabel:=0
    Selection.MoveStart Unit:=wdLine, Count:=-1
    Set rng = Selection.Range
    ActiveDocument.Range(rng.Start + Len("Figure"), rng.Start + Len("Figure") + 1).Text = ChrW(160)
    
    Selection.MoveStart Unit:=wdLine, Count:=1

Compared to the earlier code I now use Label:=wdCaptionFigure or Label:= wdCaptionTable to set the label type. My question now is if there is a way to find out, for example via the Len operation the length of the generated label depending on the given WdCaptionLabelID enumeration parameter, instead of using Len("Figure") or Len("Table").

Thanks

Reasons:
  • Blacklisted phrase (0.5): Thanks
  • Long answer (-1):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Martin Merkel