Solved

add bookmark label to 78 documents

Posted on 2016-08-10
2
72 Views
Last Modified: 2016-08-10
i have a folder which has over 200 word documents  set up as a form with various bookmarks in them that will extract info from the documents to a 3rd party applicaiton. The person who made the form forgot to label one bookmark in 78 documents that have the information in the form, but the bookmark has to be added to extract the info in the field. what has to be done is this: unprotect the document, go to the book mark, add the label, protect the documents, save it, and go on to number 2. Is there a way to add the bookmark to these 78 documents in a more efficient manner? this is word 2013 on windows 7.
0
Comment
Question by:geriatricgeek
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
ID: 41750995
You could run a VBA macro like this.
Sub AddLabel()
    Dim strFile As String
    Dim doc As Document
    Dim strInfolder As String
    Dim strOutfolder As String
    Dim strLabelText As String
    Dim strBookMarkName As String
    Dim rng As Range
    
    'One off, so hard code the input data
    strInfolder = "C:\My Documents\In"
    strOutfolder = "C:\My Documents\Out"
    strBookMarkName = "MyBookmark"
    strLabelText = "Some text"
    
    strFile = Dir$(strInfolder & "*.docx*")
    Do Until strFile = ""
        Set doc = Documents.Open(strInfolder & "\" & strFile)
        doc.Unprotect 'password
        Set rng = doc.Bookmarks(strBookMarkName).Range
        rng.Text = strLabelText
        doc.Bookmarks.Add strBookMarkName, rng 're-add bookmark in case it was overwritten
        doc.Protect wdAllowOnlyFormFields, True ',password
        doc.SaveAs strOutfolder & "\" & strFile
        doc.Close wdDoNotSaveChanges
        strFile = Dir$()
    Loop
    
End Sub

Open in new window


It isn't entirely clear what the relationship between the bookmark and the label is. This macro will replace the contents (if any) of the bookmark with the given text. If this is not correct, we will need some more details.
0
 
LVL 1

Author Closing Comment

by:geriatricgeek
ID: 41751375
Looks intense. I'll give it a try. thanks
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This article describes how to import an Outlook PST file to Office 365 using a third party product to avoid Microsoft's Azure command line tool, saving you time.
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question