Solved

add bookmark label to 78 documents

Posted on 2016-08-10
2
50 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
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
PaperPort 14.5 Patch 1 update is often not detected or downloaded automatically. This article provides direct download links to solve the problem for retail (non-bundled) versions of the Standard and Professional editions, as well as the Professiona…
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now