Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / April 2007

Tip: Looking for answers? Try searching our database.

VBA ".Wrap = FindAsk" does not  work within a For Next Loop

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
GlennMc - 16 Apr 2007 19:16 GMT
I copied a macro from my normal.dot to another user's computer, but the .Wrap
statement is ignored within the For Next Loop when I run the macro on their
computer. Why would it work on mine and not theirs?
Signature

GlennMc

Jean-Guy Marcil - 16 Apr 2007 20:16 GMT
GlennMc was telling us:
GlennMc nous racontait que :

> I copied a macro from my normal.dot to another user's computer, but
> the .Wrap statement is ignored within the For Next Loop when I run
> the macro on their computer. Why would it work on mine and not theirs?

Show us your code.

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

GlennMc - 16 Apr 2007 20:34 GMT
Selection.HomeKey Unit:=wdStory

' Find and delete duplicate index fields

   For X = 1 To 2500
   Selection.Find.ClearFormatting
   With Selection.Find
       .Text = " XE "
       .Forward = True
       .Wrap = wdFindAsk
       '.Format = True
       '.MatchCase = False
       '.MatchWholeWord = False
       '.MatchWildcards = False
       '.MatchSoundsLike = False
       '.MatchAllWordForms = False
   
   End With
   
   Selection.Find.Execute
   Selection.Extend Character:=""""
   Selection.Extend Character:=""""
   
   With Selection
   
   Word1 = Selection
   If Word1 = Word3 Then
         
   Selection.Delete
   Selection.EndKey Unit:=wdLine
   Else
   Selection.EndKey Unit:=wdLine
 
   End If
   End With
   
   Selection.Find.Execute
   
   Selection.Extend Character:=""""
   Selection.Extend Character:=""""
   With Selection
   Word2 = Selection
   
   End With
   
  If Word1 = Word2 Then
       Selection.Delete
       Word3 = Word2
   Else
   Word3 = Word2
   Selection.EndKey Unit:=wdLine
 
  End If
   
  Next

Signature

GlennMc

> GlennMc was telling us:
> GlennMc nous racontait que :
[quoted text clipped - 4 lines]
>
> Show us your code.
Jean-Guy Marcil - 16 Apr 2007 21:40 GMT
GlennMc was telling us:
GlennMc nous racontait que :

> Selection.HomeKey Unit:=wdStory
>
> ' Find and delete duplicate index fields
>
>    For X = 1 To 2500

Why this arbitrary statement? Why 2500?

>    Selection.Find.ClearFormatting
>    With Selection.Find
>        .Text = " XE "

I guess there is some missing code otherwise, as is, XE may not be found if
hidden text is not shown.

>        .Forward = True
>        .Wrap = wdFindAsk
[quoted text clipped - 8 lines]
>
>    Selection.Find.Execute

I do not understand the purpose of these two lines of code:
>    Selection.Extend Character:=""""
>    Selection.Extend Character:=""""
[quoted text clipped - 31 lines]
>
>   Next

I think you forgot to show us all the relevant code, or, if not, this code
as is, may not work all the time.
Also, you never explained what you expected from
   .Wrap = wdFindAsk

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.