A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » Formatting Long Documents
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Converting field results to hard text



 
 
Thread Tools Display Modes
  #1  
Old December 9th, 2004, 09:27 PM
Thomas Payne
external usenet poster
 
Posts: n/a
Default Converting field results to hard text

I'm running XP Pro, and Word 2002.

My publisher needs me to convert my field results to hard text. Isn't there
a macro that does this? (I don't mean just F9 switching between viewing the
field and viewing the result -- I need to eliminate all the fields,
converting them into plain text that corresponds to their results).

On a related note: is there a macro that converts automatic numbering to
text numbering?

Thanks for any help.
Tom


  #2  
Old December 9th, 2004, 09:43 PM
Charles Kenyon
external usenet poster
 
Posts: n/a
Default

What follows is code that works to update all REF fields in a document. I
know that works. Then I am giving you code that I expect will do what you
want based on the macro I've tested.

Sub RefFieldUpdateAllStory()
' Written by Charles Kyle Kenyon 15 November 2001
' All Story Field Updater - Ref fields
Dim oField As Field
Dim oStory As Range
On Error Resume Next
For Each oStory In ActiveDocument.StoryRanges
' This goes into headers and footers as well as the regular document
For Each oField In ActiveDocument.Range.Fields
If oField.Type = wdFieldRef Then
oField.Update
End If
Next oField
Next oStory
End Sub

Sub FieldsUnlinkAllStory()
' Written by Charles Kyle Kenyon 9 December 2004
' All Story Field Unlinker
Dim oField As Field
Dim oStory As Range
On Error Resume Next
For Each oStory In ActiveDocument.StoryRanges
' This goes into headers and footers as well as the regular document
For Each oField In ActiveDocument.Range.Fields
oField.Unlink
Next oField
Next oStory
End Sub

There may be something less complex that will do it. If you don't have
headers/footers, text boxes or frames that contain fields you could just
use:

ActiveDocument.Fields.Unlink

Hope this helps,
--

Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://www.mvps.org/word which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.

"Thomas Payne" wrote in message
...
I'm running XP Pro, and Word 2002.

My publisher needs me to convert my field results to hard text. Isn't
there a macro that does this? (I don't mean just F9 switching between
viewing the field and viewing the result -- I need to eliminate all the
fields, converting them into plain text that corresponds to their
results).

On a related note: is there a macro that converts automatic numbering to
text numbering?

Thanks for any help.
Tom



  #3  
Old December 9th, 2004, 09:53 PM
Thomas Payne
external usenet poster
 
Posts: n/a
Default

Thank you very much. This is helpful. I also appreciate your links.

Tom


  #4  
Old December 9th, 2004, 10:07 PM
Jezebel
external usenet poster
 
Posts: n/a
Default

Charles, there are bugs in your code --

1) Currently you are updating fields only in the body of the document,
notwithstanding your loop through the StoryRanges.

For Each oStory In ActiveDocument.StoryRanges
' This goes into headers and footers as well as the regular document
For Each oField In ActiveDocument.Range.Fields -----
This is wrong

The line should be --

For Each oField In oStory.Fields


2) But even fixing that, your code will also miss fields in headers and
footers after the first section, and in textframes after the first.
Header/Footer and Textframe StoryRanges are linked lists. Iterating the
StoryRanges collection returns only the first item in the list. To get the
subsequent ranges you need something like

For Each oStory In ActiveDocument.StoryRanges

Do
oStory.Fields.Update
set oStory = oStory.Next
Loop until oStory is nothing

Next


Also there's no need to iterate the fields themselves. Once you have the
range you can operate on all its fields in one statement:

oStory.Fields.Update, oStory.field.unlink, etc




"Charles Kenyon" wrote in
message ...
What follows is code that works to update all REF fields in a document. I
know that works. Then I am giving you code that I expect will do what you
want based on the macro I've tested.

Sub RefFieldUpdateAllStory()
' Written by Charles Kyle Kenyon 15 November 2001
' All Story Field Updater - Ref fields
Dim oField As Field
Dim oStory As Range
On Error Resume Next
For Each oStory In ActiveDocument.StoryRanges
' This goes into headers and footers as well as the regular document
For Each oField In ActiveDocument.Range.Fields
If oField.Type = wdFieldRef Then
oField.Update
End If
Next oField
Next oStory
End Sub

Sub FieldsUnlinkAllStory()
' Written by Charles Kyle Kenyon 9 December 2004
' All Story Field Unlinker
Dim oField As Field
Dim oStory As Range
On Error Resume Next
For Each oStory In ActiveDocument.StoryRanges
' This goes into headers and footers as well as the regular document
For Each oField In ActiveDocument.Range.Fields
oField.Unlink
Next oField
Next oStory
End Sub

There may be something less complex that will do it. If you don't have
headers/footers, text boxes or frames that contain fields you could just
use:

ActiveDocument.Fields.Unlink

Hope this helps,
--

Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://www.mvps.org/word which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.

"Thomas Payne" wrote in message
...
I'm running XP Pro, and Word 2002.

My publisher needs me to convert my field results to hard text. Isn't
there a macro that does this? (I don't mean just F9 switching between
viewing the field and viewing the result -- I need to eliminate all the
fields, converting them into plain text that corresponds to their
results).

On a related note: is there a macro that converts automatic numbering to
text numbering?

Thanks for any help.
Tom





  #5  
Old December 9th, 2004, 10:07 PM
Jezebel
external usenet poster
 
Posts: n/a
Default

Ctrl-Shift-F9




"Thomas Payne" wrote in message
...
I'm running XP Pro, and Word 2002.

My publisher needs me to convert my field results to hard text. Isn't

there
a macro that does this? (I don't mean just F9 switching between viewing

the
field and viewing the result -- I need to eliminate all the fields,
converting them into plain text that corresponds to their results).

On a related note: is there a macro that converts automatic numbering to
text numbering?

Thanks for any help.
Tom




  #6  
Old December 10th, 2004, 12:26 AM
Thomas Payne
external usenet poster
 
Posts: n/a
Default

Yes, thanks. I figured that out, once I learned from Charles that the term
I should look for was "unlink."

Tom


"Jezebel" wrote in message
...
Ctrl-Shift-F9




"Thomas Payne" wrote in message
...
I'm running XP Pro, and Word 2002.

My publisher needs me to convert my field results to hard text. Isn't

there
a macro that does this? (I don't mean just F9 switching between viewing

the
field and viewing the result -- I need to eliminate all the fields,
converting them into plain text that corresponds to their results).

On a related note: is there a macro that converts automatic numbering to
text numbering?

Thanks for any help.
Tom






  #7  
Old December 10th, 2004, 05:25 PM
Charles Kenyon
external usenet poster
 
Posts: n/a
Default

Thank you. I seldom work with mulit-section documents and so didn't trip
over this.


--

Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://www.mvps.org/word which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.

"Jezebel" wrote in message
...
Charles, there are bugs in your code --

1) Currently you are updating fields only in the body of the document,
notwithstanding your loop through the StoryRanges.

For Each oStory In ActiveDocument.StoryRanges
' This goes into headers and footers as well as the regular
document
For Each oField In ActiveDocument.Range.Fields -----
This is wrong

The line should be --

For Each oField In oStory.Fields


2) But even fixing that, your code will also miss fields in headers and
footers after the first section, and in textframes after the first.
Header/Footer and Textframe StoryRanges are linked lists. Iterating the
StoryRanges collection returns only the first item in the list. To get the
subsequent ranges you need something like

For Each oStory In ActiveDocument.StoryRanges

Do
oStory.Fields.Update
set oStory = oStory.Next
Loop until oStory is nothing

Next


Also there's no need to iterate the fields themselves. Once you have the
range you can operate on all its fields in one statement:

oStory.Fields.Update, oStory.field.unlink, etc




"Charles Kenyon" wrote in
message ...
What follows is code that works to update all REF fields in a document. I
know that works. Then I am giving you code that I expect will do what you
want based on the macro I've tested.

Sub RefFieldUpdateAllStory()
' Written by Charles Kyle Kenyon 15 November 2001
' All Story Field Updater - Ref fields
Dim oField As Field
Dim oStory As Range
On Error Resume Next
For Each oStory In ActiveDocument.StoryRanges
' This goes into headers and footers as well as the regular document
For Each oField In ActiveDocument.Range.Fields
If oField.Type = wdFieldRef Then
oField.Update
End If
Next oField
Next oStory
End Sub

Sub FieldsUnlinkAllStory()
' Written by Charles Kyle Kenyon 9 December 2004
' All Story Field Unlinker
Dim oField As Field
Dim oStory As Range
On Error Resume Next
For Each oStory In ActiveDocument.StoryRanges
' This goes into headers and footers as well as the regular document
For Each oField In ActiveDocument.Range.Fields
oField.Unlink
Next oField
Next oStory
End Sub

There may be something less complex that will do it. If you don't have
headers/footers, text boxes or frames that contain fields you could just
use:

ActiveDocument.Fields.Unlink

Hope this helps,
--

Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://www.mvps.org/word which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.

"Thomas Payne" wrote in message
...
I'm running XP Pro, and Word 2002.

My publisher needs me to convert my field results to hard text. Isn't
there a macro that does this? (I don't mean just F9 switching between
viewing the field and viewing the result -- I need to eliminate all the
fields, converting them into plain text that corresponds to their
results).

On a related note: is there a macro that converts automatic numbering
to
text numbering?

Thanks for any help.
Tom







  #8  
Old December 10th, 2004, 06:39 PM
Charles Kenyon
external usenet poster
 
Posts: n/a
Default

For unlinking all fields I come up with:

Sub FieldsUnlinkAllStory()
' All Story Field Unlinker
Dim oStory As Range
On Error Resume Next
For Each oStory In ActiveDocument.StoryRanges
Do
oStory.Fields.Unlink
Set oStory = oStory.Next
Loop Until oStory Is Nothing
Next
End Sub

The reason, in the original macro, for iterating through the fields was to
test for field type. That macro was only to update REF fields and not other
fields. I think this is because in some instances it is used in documents
that have ASK or fill-in fields.

What I come up with for the one that only updates Ref fields, then, is:
Sub RefFieldUpdateAllStory()
' Written by Charles Kyle Kenyon 15 November 2001
' repaired with help from Jezebel
' All Story Field Updater - Ref fields
Dim oField As Field
Dim oStory As Range
For Each oStory In ActiveDocument.StoryRanges
' This goes into headers and footers as well as the regular document
Do
For Each oField In oStory.Fields
If oField.Type = wdFieldRef Then
oField.Update
End If
Next oField
Set oStory = oStory.Next
Loop Until oStory Is Nothing
Next oStory
End Sub

I'm still not sure why the loop should get me through different sections
when the iteration does not but I accept your advice that it does. It also
seems as if this goes through each storyrange twice. I guess that just shows
my lack of understanding of these structures.

Thank you again.
--

Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://www.mvps.org/word which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.


"Jezebel" wrote in message
...
Charles, there are bugs in your code --

1) Currently you are updating fields only in the body of the document,
notwithstanding your loop through the StoryRanges.

For Each oStory In ActiveDocument.StoryRanges
' This goes into headers and footers as well as the regular
document
For Each oField In ActiveDocument.Range.Fields -----
This is wrong

The line should be --

For Each oField In oStory.Fields


2) But even fixing that, your code will also miss fields in headers and
footers after the first section, and in textframes after the first.
Header/Footer and Textframe StoryRanges are linked lists. Iterating the
StoryRanges collection returns only the first item in the list. To get the
subsequent ranges you need something like

For Each oStory In ActiveDocument.StoryRanges

Do
oStory.Fields.Update
set oStory = oStory.Next
Loop until oStory is nothing

Next


Also there's no need to iterate the fields themselves. Once you have the
range you can operate on all its fields in one statement:

oStory.Fields.Update, oStory.field.unlink, etc




"Charles Kenyon" wrote in
message ...
What follows is code that works to update all REF fields in a document. I
know that works. Then I am giving you code that I expect will do what you
want based on the macro I've tested.

Sub RefFieldUpdateAllStory()
' Written by Charles Kyle Kenyon 15 November 2001
' All Story Field Updater - Ref fields
Dim oField As Field
Dim oStory As Range
On Error Resume Next
For Each oStory In ActiveDocument.StoryRanges
' This goes into headers and footers as well as the regular document
For Each oField In ActiveDocument.Range.Fields
If oField.Type = wdFieldRef Then
oField.Update
End If
Next oField
Next oStory
End Sub

Sub FieldsUnlinkAllStory()
' Written by Charles Kyle Kenyon 9 December 2004
' All Story Field Unlinker
Dim oField As Field
Dim oStory As Range
On Error Resume Next
For Each oStory In ActiveDocument.StoryRanges
' This goes into headers and footers as well as the regular document
For Each oField In ActiveDocument.Range.Fields
oField.Unlink
Next oField
Next oStory
End Sub

There may be something less complex that will do it. If you don't have
headers/footers, text boxes or frames that contain fields you could just
use:

ActiveDocument.Fields.Unlink

Hope this helps,
--

Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://www.mvps.org/word which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.

"Thomas Payne" wrote in message
...
I'm running XP Pro, and Word 2002.

My publisher needs me to convert my field results to hard text. Isn't
there a macro that does this? (I don't mean just F9 switching between
viewing the field and viewing the result -- I need to eliminate all the
fields, converting them into plain text that corresponds to their
results).

On a related note: is there a macro that converts automatic numbering
to
text numbering?

Thanks for any help.
Tom







 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Preventing query from converting memo field to text field. Dennis In Forks Database Design 1 December 22nd, 2004 04:08 AM
Changing field contents to Hard Text LindaM General Discussion 4 November 11th, 2004 04:38 PM
Must # of fields in the 2 tables in an Append Query be equal? CreativeImages Running & Setting Up Queries 3 October 1st, 2004 05:16 PM
Please Help! A2K memo field shows eror "Too much text to edit" Lauren Wilson Using Forms 1 August 12th, 2004 04:02 AM
Is it necessary to use smaller field sizes for text ? Dewu Chen General Discussion 2 August 11th, 2004 02:32 PM


All times are GMT +1. The time now is 07:51 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.