?
Solved

add bookmark label to 78 documents

Posted on 2016-08-10
2
Medium Priority
?
78 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 2000 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

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

765 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