Share via

Cross references

Anonymous
2024-02-28T06:44:07+00:00

Hi Friends!

If I insert a CR to a bookmark and tell it to show the text of the BM, it shows the string with the formatting of the bookmarked text. Is there a way, maybe via VBA, that the CR should just be the format of the paragraph it is resting in? Also, is there a way to CR to a BM but change the display text of the CR altogether like to "Hi I am a CR" or whatever?

Thank you and have a good day!

Susan Flamingo

Microsoft 365 and Office | Word | Other | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

9 answers

Sort by: Most helpful
  1. Anonymous
    2024-02-28T12:15:19+00:00

    Hello Susan F,

    No problem, Susan! I appreciate your engagement.

    To make the REF field match the style of the paragraph, it is currently in; you can use the CharFormat switch. This switch ensures that the REF field adopts the formatting of the surrounding paragraph.

    Here’s how you can apply it:

    Insert a REF Field:

    Place your cursor where you want to insert the REF field (e.g., within the paragraph). Go to the Insert tab in Word. Choose Field from the Quick Parts dropdown. In the resulting dialog, select StyleRef from the Field Names list. From the Style Name list, choose the style you want to reference (e.g., “Subtitle”). Click OK to insert the field into the header or wherever needed.

    Add the CharFormat Switch:

    After inserting the REF field, you can modify it to include the CharFormat switch. Edit the field code by toggling the view using Alt + F9. Add the switch after the style name like this: { STYLEREF "Subtitle" \* CharFormat }

    When you update the field (e.g., by pressing F9), it will display the referenced text with the formatting of the paragraph it resides in.

    Feel free to try it, and if you have any more questions, don’t hesitate to ask!

    Kind regards, Segunfunmi.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2024-02-28T11:42:36+00:00

    Again thank you for your attention!

    Which switch in the REF field will cause it to match the style of the paragraph it is presently in?

    I don't see it.

    Sorry for the hassle

    Susan

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2024-02-28T11:27:48+00:00

    Hello Susan F,

    In order to ensure that the bookmarked text uses Char Style1, you may modify the previously provided VBA code snippet by setting the desired formatting for the oRangeBKM (bookmark range) using the . Font properties. The updated version of the VBA code snippet is as follows:

    Sub ModifyBookmarkContent() Dim oRangeBKM As Range Dim bookmarkName As String

    'Please specify the name of your bookmark bookmarkName = "YourBookmarkName"

    If ActiveDocument.Bookmarks.Exists(bookmarkName) Then 'Retrieve the range of the existing bookmark Set oRangeBKM = ActiveDocument.Bookmarks(bookmarkName). Range

    'Modify the text within the bookmark oRangeBKM.Text = "Your new content here"

    'Apply Char Style1 formatting (adjust as needed) oRangeBKM.Font.Name = "CharStyle1FontName" oRangeBKM.Font.Size = 12 'Example font size 'Add more formatting properties as required

    'Re-create the bookmark with the updated range ActiveDocument.Bookmarks.Add bookmarkName, oRangeBKM End If End Sub

    To preserve Paragraph Formatting (Style2), you may manually create a custom REF field to achieve this, as mentioned earlier. The REF field allows you to specify the desired formatting for the cross-reference text. If you need to automate this process, you may use VBA to insert the custom REF field with the appropriate switches.

    In summary, while it is challenging to achieve both requirements directly through Word's native features, a combination of VBA and custom REF fields can help you achieve the desired outcome. We advise you to adapt the code snippets to match your specific styles and needs. If you have any further questions or need additional assistance, please do not hesitate to ask.

    Best regards, Segunfunmi.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2024-02-28T11:20:30+00:00

    Thank you for your attention!

    I need the bookmarked text formatted with char style1. And the paragraph is Style2.

    So you are saying I cannot do anything to overcome this? Right?

    Was this answer helpful?

    0 comments No comments
  5. Anonymous
    2024-02-28T11:11:52+00:00

    Hello Susan F,

    I'm Segunfunmi, an Independent Advisor and Microsoft user like you. Thank you for posting your query in this forum.

    I hope you're doing well. Here are some helpful tips regarding your questions about bookmarks and formatting in Microsoft Word.

    If you want to format the text within a bookmark, you can use VBA to achieve this. You can insert a bookmark with bold and red formatting using the following code:

    Dim bmRange As Range Set bmRange = ActiveDocument.Bookmarks("YourBookmarkName"). Range With bmRange . Text = "Your Text Here" . Font.Bold = True . Font.Color = wdColorRed End With

    Replace "YourBookmarkName" and "Your Text Here" with your bookmark name and desired text. This will allow you to customize the formatting of the bookmark text.

    Unfortunately, Word doesn't directly support changing the display text of a bookmark. However, you can use a workaround by inserting an ActiveX text box (or label) instead of a bookmark. Then, handle the change event (or LostFocus event) for the text box to update the label's caption. This way, you can control the display text independently of the bookmarked content. Remember that this approach is not as straightforward as using bookmarks, but it allows you to customize the display text while maintaining the desired formatting.

    I hope these solutions are helpful for your specific needs. If you have any questions or need further assistance, please don't hesitate to ask. Have a great day!

    Kind regards, Segunfunmi.

    Was this answer helpful?

    0 comments No comments