Solved

add bookmark label to 78 documents

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Online collaboration is quickly becoming embedded in the workplace, and its benefits are tangible. See what the current landscape looks like and what the future holds for collaboration tools and the future of work.
PaperPort has a feature called the "Send To Bar". It provides a convenient, drag-and-drop interface for using other installed software, such as Microsoft Office. However, this article shows that the latest Office 2016 apps (installed with an Office …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

867 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

16 Experts available now in Live!

Get 1:1 Help Now