0

I took the following two lines of code from the site http://blogs.infoextract.in/bookmark-object-word-vba/

 ActiveDocument.Bookmarks("InfoExtractBookmark").Range.BookmarkID

 ActiveDocument.Bookmarks("InfoExtractBookmark").Select

When I run the first line of code in VBA Editor in Word, it is reporting an error. The second line does not report any error when I ran it alone. Even though bookmarking is there in the document, it does not get selected.

Could anyone explain please?

4
  • 1
    When I run the first line of code in VBA Editor in Word, it is reporting an error. BookmarkID is a property which must be assigned to something (variable of proper type, for example). You cannot call it as a method, or you must specifyCall keyword (in that case the code is executed, but the returned value will be lost).
    – Akina
    Sep 13, 2019 at 11:23
  • @Akina Based on your comment, I assigned it to a integer variable and got the total number of bookmarks which in the present case was just 1 only. Sep 13, 2019 at 11:51
  • 1
    I assigned it to a integer variable and got the total number of bookmarks which in the present case was just 1 only. No, you got specified bookmark identifier, not bookmarks count. Their equality is an accident.
    – Akina
    Sep 13, 2019 at 11:54
  • Oh my God. Understood your point. @Akina Sep 13, 2019 at 11:58

0

You must log in to answer this question.

Browse other questions tagged .