Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
mturner296 mturner296 is offline
external usenet poster
 
Posts: 8
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
mturner296 mturner296 is offline
external usenet poster
 
Posts: 8
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
mturner296 mturner296 is offline
external usenet poster
 
Posts: 8
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default 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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
automatically extract footnotes into new file and €¦ hrdwa Microsoft Word Help 14 February 28th 10 01:56 PM
extract text form document BDB Microsoft Word Help 5 June 4th 08 04:16 AM
word does not automatically replace selected text rosieh Microsoft Word Help 4 February 19th 08 05:45 PM
Can I extract specific sections from a Word Doc automatically? CRobb Microsoft Word Help 1 March 22nd 06 06:04 AM
Extract text from a word-document in rtf-format without using the clipboard Christoph Hilmes Microsoft Word Help 1 June 17th 05 02:23 PM


All times are GMT +1. The time now is 04:17 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"