Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
jezzica85 jezzica85 is offline
external usenet poster
 
Posts: 71
Default Changing field results without automatic change to the field?

Hi all,
First of all, thank you to Graham for answering my question earlier. I have
one more that's sort of in the same vein, but I'm not sure if it's exactly
the same thing. You know how Word adds a MERGEFORMAT field when you select a
field and apply new formatting to it? I looked that up and found out that was
an automatic change that you can undo and still keep the formatting. Is there
a way to turn off that automatic change, so you can change formatting
temporarily, but then it can go back to the original form on the next update
because there's no MERGEFORMAT switch added? I have lots of fields this would
apply to, and it would be a real pain to go through all of them and remove
the MERGEFORMAT.

Thanks again!
Jezzica85
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Changing field results without automatic change to the field?

I am not sure what you are asking here - but removal of mergeformat switches
is simple enough. The following macro will remove the switches or replace
the with charformat switches. See the notes in the macro.
http://www.gmayor.com/installing_macro.htm

Sub ChangeSwitch()
Dim oRng As Range
Dim iFld As Integer
Dim strChoice As String

Selection.HomeKey
ActiveDocument.ActiveWindow.View.ShowFieldCodes = True

strChoice = MsgBox("Replace Mergeformat switch with Charformat switch?" _
& vbCr & "Click 'No' to remove formatting switch completely", _
vbYesNoCancel, "Replace Formatting Switch")

If strChoice = 2 Then GoTo UserCancelled

If strChoice = vbYes Then
For iFld = ActiveDocument.Fields.Count To 1 Step -1
With ActiveDocument.Fields(iFld)

'The following line sets the field type on which the macro operates
'Remove the line to work on all fields

If .Type = wdFieldMergeField Then

If InStr(1, .Code, "MERGEFORMAT") 0 Then
.Code.Text = replace(.Code.Text, "MERGEFORMAT",
"CHARFORMAT")
End If
If InStr(1, .Code, "CHARFORMAT") = 0 Then
.Code.Text = .Code.Text & " \* CHARFORMAT "
End If

' The following block, if activated will apply a particular style to the
field(s)
' Here 'Heading 1 style"

' .Code.Select
' Set oRng = Selection.Range
' With oRng
' .Start = oRng.Characters(1).Start
' .End = oRng.Characters(2).End
' .Style = "Heading 1"
' End With

.Update
End If
End With
Next iFld
End If
If strChoice = vbNo Then
For iFld = ActiveDocument.Fields.Count To 1 Step -1
With ActiveDocument.Fields(iFld)


'The following line sets the field type on which the macro operates
'Remove the line to work on all fields

If .Type = wdFieldMergeField Then

If InStr(1, .Code, "MERGEFORMAT") 0 Then
.Code.Text = replace(.Code.Text, "\* MERGEFORMAT", "")
End If
If InStr(1, .Code, "CHARFORMAT") 0 Then
.Code.Text = replace(.Code.Text, " \* CHARFORMAT ", "")
End If
.Update
End If
End With
Next iFld
End If
ActiveDocument.ActiveWindow.View.ShowFieldCodes = False
Exit Sub

UserCancelled:
MsgBox "User Cancelled", vbInformation, "Replace Formatting Switch"
End Sub



jezzica85 wrote:
Hi all,
First of all, thank you to Graham for answering my question earlier.
I have one more that's sort of in the same vein, but I'm not sure if
it's exactly the same thing. You know how Word adds a MERGEFORMAT
field when you select a field and apply new formatting to it? I
looked that up and found out that was an automatic change that you
can undo and still keep the formatting. Is there a way to turn off
that automatic change, so you can change formatting temporarily, but
then it can go back to the original form on the next update because
there's no MERGEFORMAT switch added? I have lots of fields this would
apply to, and it would be a real pain to go through all of them and
remove the MERGEFORMAT.

Thanks again!
Jezzica85



  #3   Report Post  
Posted to microsoft.public.word.docmanagement
jezzica85 jezzica85 is offline
external usenet poster
 
Posts: 71
Default Changing field results without automatic change to the field?

Thank you again Graham!
That wasn't exactly what I needed, but it had everything in there, so I used
pieces of your code to get mine to work. Thanks a million again!
Jezzica85

"Graham Mayor" wrote:

I am not sure what you are asking here - but removal of mergeformat switches
is simple enough. The following macro will remove the switches or replace
the with charformat switches. See the notes in the macro.
http://www.gmayor.com/installing_macro.htm

Sub ChangeSwitch()
Dim oRng As Range
Dim iFld As Integer
Dim strChoice As String

Selection.HomeKey
ActiveDocument.ActiveWindow.View.ShowFieldCodes = True

strChoice = MsgBox("Replace Mergeformat switch with Charformat switch?" _
& vbCr & "Click 'No' to remove formatting switch completely", _
vbYesNoCancel, "Replace Formatting Switch")

If strChoice = 2 Then GoTo UserCancelled

If strChoice = vbYes Then
For iFld = ActiveDocument.Fields.Count To 1 Step -1
With ActiveDocument.Fields(iFld)

'The following line sets the field type on which the macro operates
'Remove the line to work on all fields

If .Type = wdFieldMergeField Then

If InStr(1, .Code, "MERGEFORMAT") 0 Then
.Code.Text = replace(.Code.Text, "MERGEFORMAT",
"CHARFORMAT")
End If
If InStr(1, .Code, "CHARFORMAT") = 0 Then
.Code.Text = .Code.Text & " \* CHARFORMAT "
End If

' The following block, if activated will apply a particular style to the
field(s)
' Here 'Heading 1 style"

' .Code.Select
' Set oRng = Selection.Range
' With oRng
' .Start = oRng.Characters(1).Start
' .End = oRng.Characters(2).End
' .Style = "Heading 1"
' End With

.Update
End If
End With
Next iFld
End If
If strChoice = vbNo Then
For iFld = ActiveDocument.Fields.Count To 1 Step -1
With ActiveDocument.Fields(iFld)


'The following line sets the field type on which the macro operates
'Remove the line to work on all fields

If .Type = wdFieldMergeField Then

If InStr(1, .Code, "MERGEFORMAT") 0 Then
.Code.Text = replace(.Code.Text, "\* MERGEFORMAT", "")
End If
If InStr(1, .Code, "CHARFORMAT") 0 Then
.Code.Text = replace(.Code.Text, " \* CHARFORMAT ", "")
End If
.Update
End If
End With
Next iFld
End If
ActiveDocument.ActiveWindow.View.ShowFieldCodes = False
Exit Sub

UserCancelled:
MsgBox "User Cancelled", vbInformation, "Replace Formatting Switch"
End Sub



jezzica85 wrote:
Hi all,
First of all, thank you to Graham for answering my question earlier.
I have one more that's sort of in the same vein, but I'm not sure if
it's exactly the same thing. You know how Word adds a MERGEFORMAT
field when you select a field and apply new formatting to it? I
looked that up and found out that was an automatic change that you
can undo and still keep the formatting. Is there a way to turn off
that automatic change, so you can change formatting temporarily, but
then it can go back to the original form on the next update because
there's no MERGEFORMAT switch added? I have lots of fields this would
apply to, and it would be a real pain to go through all of them and
remove the MERGEFORMAT.

Thanks again!
Jezzica85




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
Field results question jezzica85 Microsoft Word Help 2 November 17th 06 05:08 AM
Word field codes and results BOTH appear Carol B Microsoft Word Help 13 October 7th 06 09:19 PM
how do i edit a merged results field Lainie Mailmerge 1 September 11th 06 10:05 PM
Saving word document with field results not field codes Cambdoc Microsoft Word Help 2 July 14th 06 10:51 AM
FILLIN Field Results Tonya Marshall Microsoft Word Help 3 February 3rd 05 10:19 PM


All times are GMT +1. The time now is 02:39 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"