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 / January 2006

Tip: Looking for answers? Try searching our database.

Need a litle help please

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steved - 03 Jan 2006 23:27 GMT
Hello from Steved

The below macro is designed to firstly find : then delete everything on it's
left including : secondly move to the line below and delete 6 spaces.

Question please how do I program the below macro to stop when at the last
one the it does. ( it does 300) Thankyou.

Sub LeftMargin()
Dim i As Long
For i = 1 To ActiveDocument.Paragraphs.Count
If i > 1 Then
   Set MyRange = ActiveDocument.Paragraphs(i).Range
   MyRange.End = MyRange.Start + i
   Selection.Find.ClearFormatting
   With Selection.Find
       .Text = "^$:"
       .Replacement.Text = ""
       .Forward = True
       .Wrap = wdFindStop
       .Format = False
       .MatchCase = False
       .MatchWholeWord = False
       .MatchWildcards = False
       .MatchSoundsLike = False
       .MatchAllWordForms = False
   End With
   Selection.Find.Execute
   Selection.MoveRight Unit:=wdCharacter, Count:=1
   Selection.Extend
   Selection.HomeKey Unit:=wdLine
   Selection.Delete Unit:=wdCharacter, Count:=1
   Selection.MoveDown Unit:=wdLine, Count:=1
   Selection.Delete Unit:=wdCharacter, Count:=6
   End If
   Next i
End Sub
Steved - 04 Jan 2006 00:53 GMT
Hello from Steved

I found the answer I required by using another answer in this forum.

Thankyou.

Sub LeftMargin()
   Selection.HomeKey wdStory
   With Selection.Find
       .Text = "^$:"
       .Replacement.Text = ""
       .Forward = True
       .Wrap = wdFindAsk
       .Format = False
       .MatchCase = False
       .MatchWholeWord = False
       .MatchWildcards = False
       .MatchSoundsLike = False
       .MatchAllWordForms = False
       
       Do While .Execute

           Selection.MoveRight Unit:=wdCharacter, Count:=1
           Selection.Extend
           Selection.HomeKey Unit:=wdLine
           Selection.Delete Unit:=wdCharacter, Count:=1
           Selection.MoveDown Unit:=wdLine, Count:=1
           Selection.Delete Unit:=wdCharacter, Count:=6
       Loop
   End With
End Sub

> Hello from Steved
>
[quoted text clipped - 33 lines]
>     Next i
> End Sub

Rate this thread:






 
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.