#1
|
|||
|
|||
Processing multiple versions of the same Word doc
I need to develop a macro that methodically runs through 10 of the same word document(all saved in the same folder) and delete the filler text.
Context: I built a large document(100+ pages) and sent it out to some friends. They are filling in their own text and sending the file back to me. I only want to keep their responses. Request: Develop a macro to delete all the words I sent out, and only see their responses. The document is very rigid and should be simple to select the section i sent out. no? |
#2
|
||||
|
||||
See http://www.gmayor.com/extract_data_f...milar_docs.htm and
http://www.gmayor.com/ExtractDataFromForms.htm
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
These look great. This should be everything I need in the first link.
My follow up is how would I specify that I need the entire response extracted? without knowing how long the responses are, is it possible to point the code to look for everything after the "?" of question 1. up to the next number "2." before the question? the format of the form is: 1. What is your preferred drink at starbucks? [Please insert your answer here] (Note: this is the only space allowed for answer that is not protected in the entire document) 2. Do you ever order a breakfast sandwich? [Please insert your answer here] (Note: again, this is the only available space for editing) 3. If you were to go to Dunkin Donuts, what would you order? [Please insert your answer here] (Note: again, this is the only available space for editing) and so on and so forth. |
#4
|
||||
|
||||
You could have saved yorself a lot of grief had you used content controls for the answers, however ....
Post a sample of the document that shows how it is formatted. A page or two with example answers will suffice.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#5
|
|||
|
|||
Its not to late to edit the format of the document. For security reasons, I cannot share more than an example of the format. The wuestion format above is repeated with the answers to the sections being sent out in restrict editing mode.
Question: If I insert rich text content controls boxes and tag them(q1, q2, q3) will that make the extract easier? will i have an issue when extracting based on the fact that file names will only differ by the authors name? The authors have been instructed to submit via: INSERTNAME_starbucksorder.docx example: Jenna.starbucksorder.docx , Hank_starbucksorder.docx, so on |
#6
|
||||
|
||||
I had assumed that the forms had already gone out in their current form. As it is not too late to redesign the form, I would suggest that you use plain text content controls with the 'allow multiple paragraphs' option set.
For multiple choice questions use content control list boxes. http://www.gmayor.com/insert_content_control_addin.htm will help you insert the controls, which should have unique tags to make data recovery easier. http://www.gmayor.com/ExtractDataFromForms.htm will help you recover the returned data from the controls (and it includes a utility for checking the names and tags). The naming of the files won't matter so much, provided when you save the returned files you don't overwrite existing files with the same names.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#7
|
|||
|
|||
Thanks for the quick response. So the issue I am finding is that I can not put a discreet flag on each response.
Purpose: I want to be able to consolidate all responses from Q1. Ultimate goal: display 1 file with all 10 responses to Q1. then a new file with all 10 responses to Q2. and so on and so forth. |
#8
|
||||
|
||||
Add Q1 the tags for Q1 etc. You can then process the controls that start (or end) with Q1. Youi can edit the tags easily enough with my second link.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#9
|
|||
|
|||
so i must be doing something incorrectly then. here is my process:
1. place the content control. 2. Give each rich text content control a unique name with the same unique tag 3. run through the "Title/Tag form data fields" tool 3. is what is giving me issue. All of the filter tags appear to be the same. This is limiting me from querying a single question in the extract tool other than recoding all the content controls each time. Your help has been outstanding thus far. I really appreciate it. |
#10
|
||||
|
||||
As I said in my initial response, every tag should be unique. You can however prefix the tags with a code that would enable you to identify and process tags that share a common prefix e.g. if you have 10 responses to Q1 then each of those responses would have a unique tag so for example you could tag them as
Q1Ans1, Q1Ans2, Q1Ans3, Q1Ans4 etc You can then process content controls that have a tag that starts with Q1 to get the Q1 responses. If you copy and paste the controls they will all have the same tag. If you use the add-in to retag them, you will also currently have to title them, though I may update the add-in to not require the title. As you have a lot of controls, you could insert a control manually without title and tag and use the add-in utility to add titles and tags. If you enter only the title the tag will match the title which will save some time.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#11
|
|||
|
|||
So i will have to go in and retag the content control after I receive all ten of my responses?
Sending out the file to my recipients, the answers would have all the same field tags. Q1 will be q1 for all of my response documents. Looking at the two plug ins "Extract Data from Forms" 3.3 and 3.5, the newer version, 3.5 seems to have lost the ability to filter. Or maybe I am not following the process correctly. |
#12
|
||||
|
||||
The following macro (Macro1) will help you tag content controls in selected text, but surely you would want to tag the controls before you send out the files, in order to be able to get a meaningful result?
The extraction add-in was suggested on the basis that you wanted to extract all the data from your form. It extracts to an Excel worksheet from which you can process the data. Alternatively you can use a macro to read ony the data required (see macro2) Code:
Sub Macro1() TagControls "Q1Ans" End Sub Sub Macro2() ReadControls "Q1Ans" End Sub Sub TagControls(strTag As String, Optional iStart As Integer = 0) 'Graham Mayor - http://www.gmayor.com - Last updated - 21 Jun 2018 Dim oCC As ContentControl Dim i As Integer For i = 1 To Selection.Range.ContentControls.Count Set oCC = Selection.Range.ContentControls(i) oCC.Tag = strTag & CStr(i + iStart) oCC.Title = strTag & CStr(i + iStart) DoEvents Next i lbl_Exit: Set oCC = Nothing Exit Sub End Sub Sub ReadControls(strTag As String) Dim oCC As ContentControl Dim oSource As Document Dim oDoc As Document Set oSource = ActiveDocument Set oDoc = Documents.Add For Each oCC In oSource.ContentControls If oCC.Tag Like strTag & "*" Then If oCC.ShowingPlaceholderText = False Then oDoc.Range.InsertAfter oCC.Range.Text & vbCr End If End If DoEvents Next oCC lbl_Exit: Set oCC = Nothing Exit Sub End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#13
|
|||
|
|||
I think this is exactly what I need.
My initial problem was that I am only sending one file out to all recipients and they will return it with a separate header in the file name. Thus I will essentially have 10 separate "Q1ans" but i will not have "Q1ans1", "Q1ans2", "Q1ans3" and so on and so forth. |
#14
|
||||
|
||||
OK. You'll need to change it so that instead of having 10 separate Q1Ans they will have numbered Q1Ans (though if using the macro I posted you can still read them if they all have the same Tag) Content controls can have the same tag if you must.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
Tags |
delete text |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Multiple versions of document in one (i.e. hide section) | MatKus | Word | 4 | 03-20-2018 05:53 AM |
Is there a way to modify multiple versions of a document simultaneously? | junkman | Word | 6 | 09-08-2017 07:37 AM |
Saving multiple versions of a file automatically | NickPetrofski | Word | 7 | 07-31-2017 04:14 PM |
Batch processing:How to format multiple images (art effects & color) and then save them,all at once? | spbone | Word VBA | 2 | 01-12-2016 04:46 AM |
Multiple versions of Office on the same network. | whatrudoingdave | Office | 1 | 04-30-2012 03:36 PM |