Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
How to automatically extract selected text to a new document
I want to create an encyclopedia document full of boilerplate sections. The
user will then go through this document, identifying somehow the sections he/she is interested in, and then "push a button" and all the sections are extracted to a new document. Contrary to what this post title implies, I don't want to have to individually select each piece of text and then copy-and-paste or drag-and-drop it to the new document. I want all selected sections to be moved all at once in one step. A reasonable interface for the user to identify desired sections seems to be to use a checkbox. However, I don't know how to define the scope of text associated with that checkbox, nor how to do the actual extraction to the new document. I'm not aware that this is a standard feature in Word, so I'm assuming some amount of macro or post-processing will be needed. Any ideas about how to do this? Thanks -- Mark |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
How to automatically extract selected text to a new document
One possibility would be to create your document as a two column table, with
or without borders. Make the first column wide enough to accommodate a check box in each cell. Put your texts in the cells of the right column and protect the document for forms. Check the required check boxed in the left column and run one of the following macros to write the associated right column entries to a new document. Dim oDoc As Document Dim oNewDoc As Document Dim oFld As FormFields Dim oTable As Table Dim oRng As Range Dim i As Integer Set oDoc = ActiveDocument Set oNewDoc = Documents.Add Set oFld = oDoc.FormFields Set oTable = oDoc.Tables(1) For i = 1 To oFld.Count If oFld(i).Type = wdFieldFormCheckBox Then If oFld(i).CheckBox.Value = True Then Set oRng = oTable.Cell(i, 2).Range oNewDoc.Range.InsertAfter oRng.Text End If End If Next i OR ************** Dim oDoc As Document Dim oNewDoc As Document Dim oFld As FormFields Dim oTable As Table Dim oRng As Range, oNewRng As Range Dim i As Integer Set oDoc = ActiveDocument Set oNewDoc = Documents.Add Set oFld = oDoc.FormFields Set oTable = oDoc.Tables(1) If oDoc.ProtectionType wdNoProtection Then oDoc.Unprotect Password:="" End If For i = 1 To oFld.Count If oFld(i).Type = wdFieldFormCheckBox Then If oFld(i).CheckBox.Value = True Then Set oRng = oTable.Cell(i, 2).Range oRng.Copy Set oNewRng = oNewDoc.Range oNewRng.Start = oNewRng.End oNewRng.Paste End If End If Next i oDoc.Protect _ Type:=wdAllowOnlyFormFields, _ NoReset:=True, _ Password:="" to paste the formatted entries to a new document http://www.gmayor.com/installing_macro.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org "mturner296" wrote in message ... I want to create an encyclopedia document full of boilerplate sections. The user will then go through this document, identifying somehow the sections he/she is interested in, and then "push a button" and all the sections are extracted to a new document. Contrary to what this post title implies, I don't want to have to individually select each piece of text and then copy-and-paste or drag-and-drop it to the new document. I want all selected sections to be moved all at once in one step. A reasonable interface for the user to identify desired sections seems to be to use a checkbox. However, I don't know how to define the scope of text associated with that checkbox, nor how to do the actual extraction to the new document. I'm not aware that this is a standard feature in Word, so I'm assuming some amount of macro or post-processing will be needed. Any ideas about how to do this? Thanks -- Mark |
#3
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
How to automatically extract selected text to a new document
One possibility would be to create your document as a two column table, with
or without borders. Make the first column wide enough to accommodate a check box in each cell. Put your texts in the cells of the right column and protect the document for forms. Check the required check boxed in the left column and run one of the following macros to write the associated right column entries to a new document. Dim oDoc As Document Dim oNewDoc As Document Dim oFld As FormFields Dim oTable As Table Dim oRng As Range Dim i As Integer Set oDoc = ActiveDocument Set oNewDoc = Documents.Add Set oFld = oDoc.FormFields Set oTable = oDoc.Tables(1) For i = 1 To oFld.Count If oFld(i).Type = wdFieldFormCheckBox Then If oFld(i).CheckBox.Value = True Then Set oRng = oTable.Cell(i, 2).Range oNewDoc.Range.InsertAfter oRng.Text End If End If Next i OR ************** Dim oDoc As Document Dim oNewDoc As Document Dim oFld As FormFields Dim oTable As Table Dim oRng As Range, oNewRng As Range Dim i As Integer Set oDoc = ActiveDocument Set oNewDoc = Documents.Add Set oFld = oDoc.FormFields Set oTable = oDoc.Tables(1) If oDoc.ProtectionType wdNoProtection Then oDoc.Unprotect Password:="" End If For i = 1 To oFld.Count If oFld(i).Type = wdFieldFormCheckBox Then If oFld(i).CheckBox.Value = True Then Set oRng = oTable.Cell(i, 2).Range oRng.Copy Set oNewRng = oNewDoc.Range oNewRng.Start = oNewRng.End oNewRng.Paste End If End If Next i oDoc.Protect _ Type:=wdAllowOnlyFormFields, _ NoReset:=True, _ Password:="" to paste the formatted entries to a new document http://www.gmayor.com/installing_macro.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org "mturner296" wrote in message ... I want to create an encyclopedia document full of boilerplate sections. The user will then go through this document, identifying somehow the sections he/she is interested in, and then "push a button" and all the sections are extracted to a new document. Contrary to what this post title implies, I don't want to have to individually select each piece of text and then copy-and-paste or drag-and-drop it to the new document. I want all selected sections to be moved all at once in one step. A reasonable interface for the user to identify desired sections seems to be to use a checkbox. However, I don't know how to define the scope of text associated with that checkbox, nor how to do the actual extraction to the new document. I'm not aware that this is a standard feature in Word, so I'm assuming some amount of macro or post-processing will be needed. Any ideas about how to do this? Thanks -- Mark |
#4
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
How to automatically extract selected text to a new document
Thanks, that worked great. (And thanks for the pointer showing how to
install macros, etc.) My only problem now is that I would like it to preserve the original formatting from the boilerplate document in the new document. It just seems to paste it into a "Normal" paragraph style. As far as I can tell, I have the same style set active in both documents. But I am going to try teaching myself VBA and figure it out on my own. If I fail I will come back for help. Thanks again, -- Mark "Graham Mayor" wrote: One possibility would be to create your document as a two column table, with or without borders. Make the first column wide enough to accommodate a check box in each cell. Put your texts in the cells of the right column and protect the document for forms. Check the required check boxed in the left column and run one of the following macros to write the associated right column entries to a new document. Dim oDoc As Document Dim oNewDoc As Document Dim oFld As FormFields Dim oTable As Table Dim oRng As Range Dim i As Integer Set oDoc = ActiveDocument Set oNewDoc = Documents.Add Set oFld = oDoc.FormFields Set oTable = oDoc.Tables(1) For i = 1 To oFld.Count If oFld(i).Type = wdFieldFormCheckBox Then If oFld(i).CheckBox.Value = True Then Set oRng = oTable.Cell(i, 2).Range oNewDoc.Range.InsertAfter oRng.Text End If End If Next i OR ************** Dim oDoc As Document Dim oNewDoc As Document Dim oFld As FormFields Dim oTable As Table Dim oRng As Range, oNewRng As Range Dim i As Integer Set oDoc = ActiveDocument Set oNewDoc = Documents.Add Set oFld = oDoc.FormFields Set oTable = oDoc.Tables(1) If oDoc.ProtectionType wdNoProtection Then oDoc.Unprotect Password:="" End If For i = 1 To oFld.Count If oFld(i).Type = wdFieldFormCheckBox Then If oFld(i).CheckBox.Value = True Then Set oRng = oTable.Cell(i, 2).Range oRng.Copy Set oNewRng = oNewDoc.Range oNewRng.Start = oNewRng.End oNewRng.Paste End If End If Next i oDoc.Protect _ Type:=wdAllowOnlyFormFields, _ NoReset:=True, _ Password:="" to paste the formatted entries to a new document http://www.gmayor.com/installing_macro.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org "mturner296" wrote in message ... I want to create an encyclopedia document full of boilerplate sections. The user will then go through this document, identifying somehow the sections he/she is interested in, and then "push a button" and all the sections are extracted to a new document. Contrary to what this post title implies, I don't want to have to individually select each piece of text and then copy-and-paste or drag-and-drop it to the new document. I want all selected sections to be moved all at once in one step. A reasonable interface for the user to identify desired sections seems to be to use a checkbox. However, I don't know how to define the scope of text associated with that checkbox, nor how to do the actual extraction to the new document. I'm not aware that this is a standard feature in Word, so I'm assuming some amount of macro or post-processing will be needed. Any ideas about how to do this? Thanks -- Mark . |
#5
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
How to automatically extract selected text to a new document
Thanks, that worked great. (And thanks for the pointer showing how to
install macros, etc.) My only problem now is that I would like it to preserve the original formatting from the boilerplate document in the new document. It just seems to paste it into a "Normal" paragraph style. As far as I can tell, I have the same style set active in both documents. But I am going to try teaching myself VBA and figure it out on my own. If I fail I will come back for help. Thanks again, -- Mark "Graham Mayor" wrote: One possibility would be to create your document as a two column table, with or without borders. Make the first column wide enough to accommodate a check box in each cell. Put your texts in the cells of the right column and protect the document for forms. Check the required check boxed in the left column and run one of the following macros to write the associated right column entries to a new document. Dim oDoc As Document Dim oNewDoc As Document Dim oFld As FormFields Dim oTable As Table Dim oRng As Range Dim i As Integer Set oDoc = ActiveDocument Set oNewDoc = Documents.Add Set oFld = oDoc.FormFields Set oTable = oDoc.Tables(1) For i = 1 To oFld.Count If oFld(i).Type = wdFieldFormCheckBox Then If oFld(i).CheckBox.Value = True Then Set oRng = oTable.Cell(i, 2).Range oNewDoc.Range.InsertAfter oRng.Text End If End If Next i OR ************** Dim oDoc As Document Dim oNewDoc As Document Dim oFld As FormFields Dim oTable As Table Dim oRng As Range, oNewRng As Range Dim i As Integer Set oDoc = ActiveDocument Set oNewDoc = Documents.Add Set oFld = oDoc.FormFields Set oTable = oDoc.Tables(1) If oDoc.ProtectionType wdNoProtection Then oDoc.Unprotect Password:="" End If For i = 1 To oFld.Count If oFld(i).Type = wdFieldFormCheckBox Then If oFld(i).CheckBox.Value = True Then Set oRng = oTable.Cell(i, 2).Range oRng.Copy Set oNewRng = oNewDoc.Range oNewRng.Start = oNewRng.End oNewRng.Paste End If End If Next i oDoc.Protect _ Type:=wdAllowOnlyFormFields, _ NoReset:=True, _ Password:="" to paste the formatted entries to a new document http://www.gmayor.com/installing_macro.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org "mturner296" wrote in message ... I want to create an encyclopedia document full of boilerplate sections. The user will then go through this document, identifying somehow the sections he/she is interested in, and then "push a button" and all the sections are extracted to a new document. Contrary to what this post title implies, I don't want to have to individually select each piece of text and then copy-and-paste or drag-and-drop it to the new document. I want all selected sections to be moved all at once in one step. A reasonable interface for the user to identify desired sections seems to be to use a checkbox. However, I don't know how to define the scope of text associated with that checkbox, nor how to do the actual extraction to the new document. I'm not aware that this is a standard feature in Word, so I'm assuming some amount of macro or post-processing will be needed. Any ideas about how to do this? Thanks -- Mark . |
#6
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
How to automatically extract selected text to a new document
The second of the quoted macros simply uses paste to paste from one document
to the other and should preserve the formatting. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org "mturner296" wrote in message ... Thanks, that worked great. (And thanks for the pointer showing how to install macros, etc.) My only problem now is that I would like it to preserve the original formatting from the boilerplate document in the new document. It just seems to paste it into a "Normal" paragraph style. As far as I can tell, I have the same style set active in both documents. But I am going to try teaching myself VBA and figure it out on my own. If I fail I will come back for help. Thanks again, -- Mark "Graham Mayor" wrote: One possibility would be to create your document as a two column table, with or without borders. Make the first column wide enough to accommodate a check box in each cell. Put your texts in the cells of the right column and protect the document for forms. Check the required check boxed in the left column and run one of the following macros to write the associated right column entries to a new document. Dim oDoc As Document Dim oNewDoc As Document Dim oFld As FormFields Dim oTable As Table Dim oRng As Range Dim i As Integer Set oDoc = ActiveDocument Set oNewDoc = Documents.Add Set oFld = oDoc.FormFields Set oTable = oDoc.Tables(1) For i = 1 To oFld.Count If oFld(i).Type = wdFieldFormCheckBox Then If oFld(i).CheckBox.Value = True Then Set oRng = oTable.Cell(i, 2).Range oNewDoc.Range.InsertAfter oRng.Text End If End If Next i OR ************** Dim oDoc As Document Dim oNewDoc As Document Dim oFld As FormFields Dim oTable As Table Dim oRng As Range, oNewRng As Range Dim i As Integer Set oDoc = ActiveDocument Set oNewDoc = Documents.Add Set oFld = oDoc.FormFields Set oTable = oDoc.Tables(1) If oDoc.ProtectionType wdNoProtection Then oDoc.Unprotect Password:="" End If For i = 1 To oFld.Count If oFld(i).Type = wdFieldFormCheckBox Then If oFld(i).CheckBox.Value = True Then Set oRng = oTable.Cell(i, 2).Range oRng.Copy Set oNewRng = oNewDoc.Range oNewRng.Start = oNewRng.End oNewRng.Paste End If End If Next i oDoc.Protect _ Type:=wdAllowOnlyFormFields, _ NoReset:=True, _ Password:="" to paste the formatted entries to a new document http://www.gmayor.com/installing_macro.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org "mturner296" wrote in message ... I want to create an encyclopedia document full of boilerplate sections. The user will then go through this document, identifying somehow the sections he/she is interested in, and then "push a button" and all the sections are extracted to a new document. Contrary to what this post title implies, I don't want to have to individually select each piece of text and then copy-and-paste or drag-and-drop it to the new document. I want all selected sections to be moved all at once in one step. A reasonable interface for the user to identify desired sections seems to be to use a checkbox. However, I don't know how to define the scope of text associated with that checkbox, nor how to do the actual extraction to the new document. I'm not aware that this is a standard feature in Word, so I'm assuming some amount of macro or post-processing will be needed. Any ideas about how to do this? Thanks -- Mark . |
#7
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
How to automatically extract selected text to a new document
The second of the quoted macros simply uses paste to paste from one document to the other and should preserve the formatting. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org "mturner296" wrote in message ... Thanks, that worked great. (And thanks for the pointer showing how to install macros, etc.) My only problem now is that I would like it to preserve the original formatting from the boilerplate document in the new document. It just seems to paste it into a "Normal" paragraph style. As far as I can tell, I have the same style set active in both documents. But I am going to try teaching myself VBA and figure it out on my own. If I fail I will come back for help. Thanks again, -- Mark "Graham Mayor" wrote: One possibility would be to create your document as a two column table, with or without borders. Make the first column wide enough to accommodate a check box in each cell. Put your texts in the cells of the right column and protect the document for forms. Check the required check boxed in the left column and run one of the following macros to write the associated right column entries to a new document. Dim oDoc As Document Dim oNewDoc As Document Dim oFld As FormFields Dim oTable As Table Dim oRng As Range Dim i As Integer Set oDoc = ActiveDocument Set oNewDoc = Documents.Add Set oFld = oDoc.FormFields Set oTable = oDoc.Tables(1) For i = 1 To oFld.Count If oFld(i).Type = wdFieldFormCheckBox Then If oFld(i).CheckBox.Value = True Then Set oRng = oTable.Cell(i, 2).Range oNewDoc.Range.InsertAfter oRng.Text End If End If Next i OR ************** Dim oDoc As Document Dim oNewDoc As Document Dim oFld As FormFields Dim oTable As Table Dim oRng As Range, oNewRng As Range Dim i As Integer Set oDoc = ActiveDocument Set oNewDoc = Documents.Add Set oFld = oDoc.FormFields Set oTable = oDoc.Tables(1) If oDoc.ProtectionType wdNoProtection Then oDoc.Unprotect Password:="" End If For i = 1 To oFld.Count If oFld(i).Type = wdFieldFormCheckBox Then If oFld(i).CheckBox.Value = True Then Set oRng = oTable.Cell(i, 2).Range oRng.Copy Set oNewRng = oNewDoc.Range oNewRng.Start = oNewRng.End oNewRng.Paste End If End If Next i oDoc.Protect _ Type:=wdAllowOnlyFormFields, _ NoReset:=True, _ Password:="" to paste the formatted entries to a new document http://www.gmayor.com/installing_macro.htm -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org "mturner296" wrote in message ... I want to create an encyclopedia document full of boilerplate sections. The user will then go through this document, identifying somehow the sections he/she is interested in, and then "push a button" and all the sections are extracted to a new document. Contrary to what this post title implies, I don't want to have to individually select each piece of text and then copy-and-paste or drag-and-drop it to the new document. I want all selected sections to be moved all at once in one step. A reasonable interface for the user to identify desired sections seems to be to use a checkbox. However, I don't know how to define the scope of text associated with that checkbox, nor how to do the actual extraction to the new document. I'm not aware that this is a standard feature in Word, so I'm assuming some amount of macro or post-processing will be needed. Any ideas about how to do this? Thanks -- Mark . |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
automatically extract footnotes into new file and €¦ | Microsoft Word Help | |||
extract text form document | Microsoft Word Help | |||
word does not automatically replace selected text | Microsoft Word Help | |||
Can I extract specific sections from a Word Doc automatically? | Microsoft Word Help | |||
Extract text from a word-document in rtf-format without using the clipboard | Microsoft Word Help |