Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
paraakaram paraakaram is offline
external usenet poster
 
Posts: 3
Default Macro behaving differenlty on different computers

Hi there,


The problem is that, I have written this macro, which would find the "SET"
type of fields inside the document
and then replace the text inside the "SET Field" with text I pass

This is the macro

/*This would open the document which contains set field*/

Application.Documents.Open ("C:/Test Field.doc")
Application.Visible = True
Call merging
/*Here call is made to another macro */


/*This would try replacing the text inside the set field*/

If ActiveDocument.Fields.Count 0 Then
For i = 1 To ActiveDocument.Fields.Count
ActiveDocument.Fields.Add
Range:=ActiveDocument.Fields.Item(1).Code.Previous , _
Type:=wdFieldEmpty, _
Text:="SET F256_1 NewText"
ActiveDocument.Fields.Update
Next
End If

The strange part here is, this works perfectly on my system (Word 2003)
but there is a system in my lab where this instead of replacing the text
inside the set field
would insert new set field in the document

It is very strange because only this system shows such a behavior (it has
msword 2002 SP3 )

Thanks & Kind Regards
Paraakaram

  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Macro behaving differenlty on different computers

You are adding a field rather than replacing the content?
You also appear to have a redundant for/next loop?

Dim strCodes As String
strCodes = ActiveDocument.ActiveWindow.View.ShowFieldCodes
ActiveDocument.ActiveWindow.View.ShowFieldCodes = True
Selection.HomeKey
With ActiveDocument.Fields(1)
.Code.Text = Replace(.Code.Text, _
.Code, "SET F256_1 NewText")
.Update
End With
ActiveDocument.ActiveWindow.View.ShowFieldCodes = strCodes

may be closer to what you want, if there is only the first field involved


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org





paraakaram wrote:
Hi there,


The problem is that, I have written this macro, which would find the
"SET" type of fields inside the document
and then replace the text inside the "SET Field" with text I pass

This is the macro

/*This would open the document which contains set field*/

Application.Documents.Open ("C:/Test Field.doc")
Application.Visible = True
Call merging
/*Here call is made to another macro */


/*This would try replacing the text inside the set field*/

If ActiveDocument.Fields.Count 0 Then
For i = 1 To ActiveDocument.Fields.Count
ActiveDocument.Fields.Add
Range:=ActiveDocument.Fields.Item(1).Code.Previous , _
Type:=wdFieldEmpty, _
Text:="SET F256_1 NewText"
ActiveDocument.Fields.Update
Next
End If

The strange part here is, this works perfectly on my system (Word
2003) but there is a system in my lab where this instead of replacing
the text inside the set field
would insert new set field in the document

It is very strange because only this system shows such a behavior (it
has msword 2002 SP3 )

Thanks & Kind Regards
Paraakaram



  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
paraakaram paraakaram is offline
external usenet poster
 
Posts: 3
Default Macro behaving differenlty on different computers

Hi Graham

Thank you for your reply

Your reply is correct but there is a surprising fact here,

The macro I have written to replace the text inside the field
works fine for all the computers except one system.

What I mean is that, though the way I followed to achieve my requirement
is not perfectly correct unlike yours but it is achieving what I wanted on
all the
system except one, where the another "SET" field gets added instead of
replacing
action taking place.

Thank you for such a prompt reply

Kind Regards
Paraakaram




"Graham Mayor" wrote:

You are adding a field rather than replacing the content?
You also appear to have a redundant for/next loop?

Dim strCodes As String
strCodes = ActiveDocument.ActiveWindow.View.ShowFieldCodes
ActiveDocument.ActiveWindow.View.ShowFieldCodes = True
Selection.HomeKey
With ActiveDocument.Fields(1)
.Code.Text = Replace(.Code.Text, _
.Code, "SET F256_1 NewText")
.Update
End With
ActiveDocument.ActiveWindow.View.ShowFieldCodes = strCodes

may be closer to what you want, if there is only the first field involved


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org





paraakaram wrote:
Hi there,


The problem is that, I have written this macro, which would find the
"SET" type of fields inside the document
and then replace the text inside the "SET Field" with text I pass

This is the macro

/*This would open the document which contains set field*/

Application.Documents.Open ("C:/Test Field.doc")
Application.Visible = True
Call merging
/*Here call is made to another macro */


/*This would try replacing the text inside the set field*/

If ActiveDocument.Fields.Count 0 Then
For i = 1 To ActiveDocument.Fields.Count
ActiveDocument.Fields.Add
Range:=ActiveDocument.Fields.Item(1).Code.Previous , _
Type:=wdFieldEmpty, _
Text:="SET F256_1 NewText"
ActiveDocument.Fields.Update
Next
End If

The strange part here is, this works perfectly on my system (Word
2003) but there is a system in my lab where this instead of replacing
the text inside the set field
would insert new set field in the document

It is very strange because only this system shows such a behavior (it
has msword 2002 SP3 )

Thanks & Kind Regards
Paraakaram




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
Bullet points not behaving Voldemore Microsoft Word Help 8 April 19th 14 09:52 PM
Document Behaving Strangely Ross Payne New Users 3 March 22nd 07 08:26 AM
TOC starts behaving strangely Jonathan Stratford Page Layout 6 July 25th 05 03:16 PM
Avery Wizard behaving oddly Bob Fliegel Microsoft Word Help 0 July 16th 05 05:55 PM
Document Map not behaving Mary Lee Page Layout 3 May 16th 05 08:19 PM


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

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"