Skip to main content
deleted 9 characters in body
Source Link

Recently I had the pleasure to review a few specification documents edited in MS Word, containing around 1000 tables and figures, each of those with a caption that did not separate caption label and number with a non-breaking space but a regular white space instead. This resulted fairly frequently in situations where for example Table was at the end of one line, and the corresponding number of the start of the next line, making the document more difficult to read.

At the end I inserted the non-breaking space manually into each of the captions manually. To avoid this for future specification documents, I created VBA macros that create the tables and captions, but I still need to figure out how to get the caption formatting sorted out. Currently my code is (simplified) like this:

Sub MyTableMacro()
    ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=4, NumColumns:= _
        4, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
        wdAutoFitFixed
    With Selection.Tables(1)
    ...
    ...
    End With
    Selection.InsertCaption Label:="Table", Title:=" " + ChrW(8212) + " My table title", Position:=wdCaptionPositionAbove, ExcludeLabel:=0
End Sub

I reviewed the article here but cannot figure out what needs to modified in my code snippet above to apply the proposed method. As an extra, I'm using an English MS Word on a Windows PC, but it needs to work also on German language MACs (which messed up my first attempt with the em dash). Thanks for hints.

Recently I had the pleasure to review a few specification documents edited in MS Word, containing around 1000 tables and figures, each of those with a caption that did not separate caption label and number with a non-breaking space but a regular white space instead. This resulted fairly frequently in situations where for example Table was at the end of one line, and the corresponding number of the start of the next line, making the document more difficult to read.

At the end I inserted the non-breaking space manually into each of the captions manually. To avoid this for future specification documents, I created VBA macros that create the tables and captions, but I still need to figure out how to get the caption formatting sorted out. Currently my code is (simplified) like this:

Sub MyTableMacro()
    ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=4, NumColumns:= _
        4, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
        wdAutoFitFixed
    With Selection.Tables(1)
    ...
    ...
    End With
    Selection.InsertCaption Label:="Table", Title:=" " + ChrW(8212) + " My table title", Position:=wdCaptionPositionAbove, ExcludeLabel:=0
End Sub

I reviewed the article here but cannot figure out what needs to modified in my code snippet above to apply the proposed method. As an extra, I'm using an English MS Word on a Windows PC, but it needs to work also on German language MACs (which messed up my first attempt with the em dash). Thanks for hints.

Recently I had the pleasure to review a few specification documents edited in MS Word, containing around 1000 tables and figures, each of those with a caption that did not separate caption label and number with a non-breaking space but a regular white space instead. This resulted fairly frequently in situations where for example Table was at the end of one line, and the corresponding number of the start of the next line, making the document more difficult to read.

At the end I inserted the non-breaking space into each of the captions manually. To avoid this for future specification documents, I created VBA macros that create the tables and captions, but I still need to figure out how to get the caption formatting sorted out. Currently my code is (simplified) like this:

Sub MyTableMacro()
    ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=4, NumColumns:= _
        4, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
        wdAutoFitFixed
    With Selection.Tables(1)
    ...
    ...
    End With
    Selection.InsertCaption Label:="Table", Title:=" " + ChrW(8212) + " My table title", Position:=wdCaptionPositionAbove, ExcludeLabel:=0
End Sub

I reviewed the article here but cannot figure out what needs to modified in my code snippet above to apply the proposed method. As an extra, I'm using an English MS Word on a Windows PC, but it needs to work also on German language MACs (which messed up my first attempt with the em dash). Thanks for hints.

added 1 character in body
Source Link

Recently I had the pleasure to review a few specification documents edited in MS Word, containing around 1000 tables and figures, each of those with a caption that did not separate caption label and number with a non-breaking space but a regular white space instead. This resulted fairly frequently in situationsituations where for example Table was at the end of one line, and the corresponding number of the start of the next line, making the document more difficult to read.

At the end I inserted the non-breaking space manually into each of the captions manually. To avoid this for future specification documents, I created VBA macros that create the tables and captions, but I still need to figure out how to get the caption formatting sorted out. Currently my code is (simplified) like this:

Sub MyTableMacro()
    ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=4, NumColumns:= _
        4, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
        wdAutoFitFixed
    With Selection.Tables(1)
    ...
    ...
    End With
    Selection.InsertCaption Label:="Table", Title:=" " + ChrW(8212) + " My table title", Position:=wdCaptionPositionAbove, ExcludeLabel:=0
End Sub

I reviewed the article here but cannot figure out what needs to modified in my code snippet above to apply the proposed method. As an extra, I'm using an English MS Word on a Windows PC, but it needs to work also on German language MACs (which messed up my first attempt with the em dash). Thanks for hints.

Recently I had the pleasure to review a few specification documents edited in MS Word, containing around 1000 tables and figures, each of those with a caption that did not separate caption label and number with a non-breaking space but a regular white space instead. This resulted fairly frequently in situation where for example Table was at the end of one line, and the corresponding number of the start of the next line, making the document more difficult to read.

At the end I inserted the non-breaking space manually into each of the captions manually. To avoid this for future specification documents, I created VBA macros that create the tables and captions, but I still need to figure out how to get the caption formatting sorted out. Currently my code is (simplified) like this:

Sub MyTableMacro()
    ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=4, NumColumns:= _
        4, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
        wdAutoFitFixed
    With Selection.Tables(1)
    ...
    ...
    End With
    Selection.InsertCaption Label:="Table", Title:=" " + ChrW(8212) + " My table title", Position:=wdCaptionPositionAbove, ExcludeLabel:=0
End Sub

I reviewed the article here but cannot figure out what needs to modified in my code snippet above to apply the proposed method. As an extra, I'm using an English MS Word on a Windows PC, but it needs to work also on German language MACs (which messed up my first attempt with the em dash). Thanks for hints.

Recently I had the pleasure to review a few specification documents edited in MS Word, containing around 1000 tables and figures, each of those with a caption that did not separate caption label and number with a non-breaking space but a regular white space instead. This resulted fairly frequently in situations where for example Table was at the end of one line, and the corresponding number of the start of the next line, making the document more difficult to read.

At the end I inserted the non-breaking space manually into each of the captions manually. To avoid this for future specification documents, I created VBA macros that create the tables and captions, but I still need to figure out how to get the caption formatting sorted out. Currently my code is (simplified) like this:

Sub MyTableMacro()
    ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=4, NumColumns:= _
        4, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
        wdAutoFitFixed
    With Selection.Tables(1)
    ...
    ...
    End With
    Selection.InsertCaption Label:="Table", Title:=" " + ChrW(8212) + " My table title", Position:=wdCaptionPositionAbove, ExcludeLabel:=0
End Sub

I reviewed the article here but cannot figure out what needs to modified in my code snippet above to apply the proposed method. As an extra, I'm using an English MS Word on a Windows PC, but it needs to work also on German language MACs (which messed up my first attempt with the em dash). Thanks for hints.

Source Link

VBA Selection.InsertCaption and automatically adding non-breaking space between the label and number

Recently I had the pleasure to review a few specification documents edited in MS Word, containing around 1000 tables and figures, each of those with a caption that did not separate caption label and number with a non-breaking space but a regular white space instead. This resulted fairly frequently in situation where for example Table was at the end of one line, and the corresponding number of the start of the next line, making the document more difficult to read.

At the end I inserted the non-breaking space manually into each of the captions manually. To avoid this for future specification documents, I created VBA macros that create the tables and captions, but I still need to figure out how to get the caption formatting sorted out. Currently my code is (simplified) like this:

Sub MyTableMacro()
    ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=4, NumColumns:= _
        4, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
        wdAutoFitFixed
    With Selection.Tables(1)
    ...
    ...
    End With
    Selection.InsertCaption Label:="Table", Title:=" " + ChrW(8212) + " My table title", Position:=wdCaptionPositionAbove, ExcludeLabel:=0
End Sub

I reviewed the article here but cannot figure out what needs to modified in my code snippet above to apply the proposed method. As an extra, I'm using an English MS Word on a Windows PC, but it needs to work also on German language MACs (which messed up my first attempt with the em dash). Thanks for hints.