Share via

Problem setting a range

Anonymous
2024-08-15T05:05:28+00:00

I have a problem that I cannot seem to figure out/ Thee 4 lines below return an error "The requested member of the collection does not exist".

Set oRng14 = ActiveDocument.Bookmarks("BBCD1").Range

Set oRng15 = ActiveDocument.Bookmarks("RecCD1").Range

Set oRng16 = ActiveDocument.Bookmarks("ExpCD1").Range

Set oRng17 = ActiveDocument.Bookmarks("EBCD1").Range

Problem setting a Range

Dim oRng As Word.Range

Dim oRng01 As Word.Range

Dim oRng1 As Word.Range

Dim oRng2 As Word.Range

Dim oRng3 As Word.Range

Dim oRng4 As Word.Range

Dim oRng5 As Word.Range

Dim oRng6 As Word.Range

Dim oRng7 As Word.Range

Dim oRng8 As Word.Range

Dim oRng9 As Word.Range

Dim oRng10 As Word.Range

Dim oRng11 As Word.Range

Dim oRng12 As Word.Range

Dim oRng13 As Word.Range

Dim oRng14 As Word.Range

Dim oRng15 As Word.Range

Dim oRng16 As Word.Range

Dim oRng17 As Word.Range

        Set oRng = ActiveDocument.Bookmarks("NoTreasurer").Range

        Set oRng01 = ActiveDocument.Bookmarks("Treasurer").Range

        Set oRng1 = ActiveDocument.Bookmarks("FundReportDate").Range

        Set oRng2 = ActiveDocument.Bookmarks("BBBenefit").Range

        Set oRng3 = ActiveDocument.Bookmarks("RecBenefit").Range

        Set oRng4 = ActiveDocument.Bookmarks("ExpBenefit").Range

        Set oRng5 = ActiveDocument.Bookmarks("EBBenefit").Range

        Set oRng6 = ActiveDocument.Bookmarks("BBGeneral").Range

        Set oRng7 = ActiveDocument.Bookmarks("RecGeneral").Range

        Set oRng8 = ActiveDocument.Bookmarks("ExpGeneral").Range

        Set oRng9 = ActiveDocument.Bookmarks("EBGeneral").Range

        Set oRng10 = ActiveDocument.Bookmarks("BBEarmark").Range

        Set oRng11 = ActiveDocument.Bookmarks("RecEarmark").Range

        Set oRng12 = ActiveDocument.Bookmarks("ExpEarmark").Range

        Set oRng13 = ActiveDocument.Bookmarks("EBEarmark").Range

        Set oRng14 = ActiveDocument.Bookmarks("BBCD1").Range

        Set oRng15 = ActiveDocument.Bookmarks("RecCD1").Range

        Set oRng16 = ActiveDocument.Bookmarks("ExpCD1").Range

        Set oRng17 = ActiveDocument.Bookmarks("EBCD1").Range

'    Populates the userform

        If Len(oRng1) = 0 Then

            Me.opt_NoTreasurer = 1

        Else

            Me.txt_FundReportDate = oRng1

            Me.txt_BBBenefit = oRng2

            Me.txt_RecBenefit = oRng3

            Me.txt_ExpBenefit = oRng4

            Me.txt_EBBenefit = oRng5

            Me.txt_BBGeneral = oRng6

            Me.txt_RecGeneral = oRng7

            Me.txt_ExpGeneral = oRng8

            Me.txt_EBGeneral = oRng9

            Me.txt_BBEarmark = oRng10

            Me.txt_RecEarmark = oRng11

            Me.txt_ExpEarmark = oRng12

            Me.txt_EBEarmark = oRng13

            Me.txt_BBCD1 = oRng14

            Me.txt_RecCD1 = oRng15

            Me.txt_ExpCD1 = oRng16

            Me.txt_EBCD1 = oRng17

        End If

    'Centers form on screen

        With Me

            .StartUpPosition = 0

            .Left = Application.Left + (0.5 * Application.Width) - (0.5 * .Width)

            .Top = Application.Top + (0.5 * Application.Height) - (0.5 * .Height)

        End With

End Sub

Microsoft 365 and Office | Word | For home | 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

3 answers

Sort by: Most helpful
  1. Anonymous
    2024-08-15T08:56:17+00:00

    Dear Ordnance1,

    Welcome to the Microsoft Community.   Based on the information you have shared, I understand that you seem to have an error with the 4 lines of code containing the bookmarks when using VBA in Word, I understand how you feel and I will try my best to help you.**According to the code information you provided, we have the following two suggestions you can troubleshoot first:**1. It is recommended that you can first try to check your bookmarks BBCD1, RecCD1, ExpCD1, EBCD1 does exist in the document. You can verify this by going to the "View" tab in Word, and then go to the "Navigation Pane" to see a list of all bookmarks.2. It is recommended that you try to delete the 4 lines of code or you can change your bookmarks variable in the re-add new code to check.I would like to explain to you that after our testing, the problem you mentioned did not occur. **If you still have problems after troubleshooting, can you share your file and the executed code with us by private message if it is convenient for you?**Here are the steps to do so:①    You can send private message through the Messages link at the top right of the page.②    Check your sent PM by going to My Profile, and then selecting View private messages on the left pane of your profile page.Please feel free to let me know if you have any further updates, thanks for your understanding and support.

    Best wishes  Isabella-MSFT | Microsoft Community Support Specialist

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  2. Anonymous
    2024-08-16T04:58:28+00:00

    Dear Ordnance1,

    Thank you very much for your reply and feedback, we trust that you will be successful in resolving your issue once you have set it up.   If the suggestions above have given you some clear direction, I hope you'll click "Yes" or "No" to help us improve the support experience and help others with similar issues find a solution. I would appreciate it.If you have any other questions, please feel free to reach out to us by posting in the community, and thanks again for your understanding and support.

    I hope everything goes well.

    Best wishes  Isabella-MSFT | Microsoft Community Support Specialist

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2024-08-16T04:47:53+00:00

    Thank yoy very much. It was in fact that I had not set the book marks

    Was this answer helpful?

    0 comments No comments