Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8188771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:01:53+00:00 2026-06-07T03:01:53+00:00

I need to generate bookmarks in Word 2010 programmatically, with the header name as

  • 0

Picture of the document

I need to generate bookmarks in Word 2010 programmatically, with the header name as the bookmark name.

I have the following code which makes a word a bookmark, but the bookmark name remains the same as the string Heading 1 is only available in the name variable:

Sub bookmarking()
    Selection.EndKey Unit:=wdLine, Extend:=wdExtend
    With ActiveDocument.Bookmarks
        .Add Range:=Selection.Range, Name:=" Heading 1"
        .DefaultSorting = wdSortByName
        .ShowHidden = False
    End With
End Sub

Instead of the Heading 1 in the name variable, I want content from the clipboard. Please help me replace that Heading 1 with clipboard content.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T03:01:55+00:00Added an answer on June 7, 2026 at 3:01 am

    Use a DataObject from the Microsoft Forms 2.0 Object Library:

    Private Function GetClipboardData()
        Dim objDataObject As MSForms.DataObject ''need to add reference in Tools |References
        Set objDataObject = New MSForms.DataObject
    
        objDataObject.GetFromClipboard
        On Error Resume Next
        GetClipboardData = objDataObject.GetText
        If Err.Number = -2147221404 Then
           MsgBox "Error: current clipboard data is either empty or is not text. Clibpoard must contain text."
        End If
    End Function
    

    Then, back your main code, have the bookmark name be this clipboard data:

    ...
    .Add Range:=Selection.Range, Name:=GetClipboardData()
    ...
    

    Is this a good start for you? There are other ways which may be more robust depending on your needs. However this should serve as good proof-of-concept.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to generate invoices in large batch which will be transformed to EDI
I need to generate a random number from 1 to 5 which isn't already
I need to generate random string for my automated tests. I use the following
I need to generate a node in a XML file with the following structure:
I need to generate external links in admin interface grid column, but they shows
I have been using addslahes() . But this escapes database characters. However I need
I am a novice in PHP. I have a URL and I need generate
Need to generate an html report from XML and corresponding XSL butI have to
I need to generate about 5,000 random numbers in my script, but the CPU
I need to generate a UUID string in some code with ARC enabled. After

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.