Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Sunrise, Florida
    Posts
    324
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Looping or Do While

    I use Word97. From bit and pieces in this forum, I built the following macro. For my goals, it works OK. However, I would like to have it repeat itself from the insertion point I select to the end of a document. I've tried with no success. Any assistance is appreciated.
    ==============================
    Sub RemoveParaMarks()
    '
    '
    Dim strCode As String
    Dim lngPadZeros As Long
    Dim ParrafoCode As String

    On Error GoTo NoSelection

    Selection.Find.ClearFormatting
    With Selection.Find
    .Text = "^p"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    End With
    Selection.Find.Execute
    Selection.MoveRight Unit:=wdCharacter, Count:=1

    strCode = CStr(Asc(Selection))
    lngPadZeros = 3 - Len(strCode)
    ParrafoCode = "^" & String$(lngPadZeros, "0") & strCode

    If ParrafoCode = "^013" Then

    Selection.MoveRight Unit:=wdCharacter, Count:=1

    Else

    Selection.MoveLeft Unit:=wdCharacter, Count:=1
    Selection.Delete Unit:=wdCharacter, Count:=1
    Selection.TypeText Text:=" "

    End If

    NoSelection:

    End Sub
    ==============================

  2. #2
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Looping or Do While

    <pre>Function LoopToEODocument()
    While Selection.End < (ActiveDocument.Content.End - 1)
    Selection.MoveRight
    Wend
    End Function
    </pre>



    Now, for your homework exercises:

    1) write one that loops to start of document and
    2) What flag is that?

    (signed) "Curious" of Toronto

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Sunrise, Florida
    Posts
    324
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Looping or Do While

    Thanks a lot! Will attempt to do #1. 'Bout #2, it's supposed to be the flag of Puerto Rico but it looks more like a strawberry pie gone bad. Take care.

  4. #4
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Sunrise, Florida
    Posts
    324
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Looping or Do While

    Thanks!

  5. #5
    Plutonium Lounger Leif's Avatar
    Join Date
    Dec 2000
    Location
    U.K.
    Posts
    14,010
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Looping or Do While

    Try this one:
    Attached Images Attached Images
    • File Type: gif x.gif (1.2 KB, 0 views)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •