In WORD 2010, Selection.InsertCrossReference fails for a Heading with no text (i.e., heading number but no text after it). It works with tables and figures with no text after the number. In the following example Heading 2.0 fails (4198), but Figure 2-2 does not fail. The Insert Cross-reference menu option is successful for both instances. However, if a macro is recorded to cross-reference to a heading and that code fails. Is there a solution?
Thanks,
John
1.0 Introduction
2.0
2.1 Approach
Figure 2-1: Diagram
Figure 2-2
strListTitle ="Heading"
'strListTitle = "Table"
'strListTitle = "Appendix_Table"
'strListTitle = "Figure"
'strListTitle = "Appendix_Figure"
RefKind = wdOnlyLabelAndNumber'
RefKind = wdNumberNoContextSelectedItem =2
Selection.InsertCrossReference ReferenceType:=strListTitle, _
ReferenceKind:= RefKind, _
ReferenceItem:=CStr(SelectedItem), _
InsertAsHyperlink:=True, _
IncludePosition:=False, _
SeparateNumbers:=False, _
SeparatorString:=" "
Thanks,
John
1.0 Introduction
2.0
2.1 Approach
Figure 2-1: Diagram
Figure 2-2
strListTitle ="Heading"
'strListTitle = "Table"
'strListTitle = "Appendix_Table"
'strListTitle = "Figure"
'strListTitle = "Appendix_Figure"
RefKind = wdOnlyLabelAndNumber'
RefKind = wdNumberNoContextSelectedItem =2
Selection.InsertCrossReference ReferenceType:=strListTitle, _
ReferenceKind:= RefKind, _
ReferenceItem:=CStr(SelectedItem), _
InsertAsHyperlink:=True, _
IncludePosition:=False, _
SeparateNumbers:=False, _
SeparatorString:=" "