Results 1 to 10 of 10

Thread: Macro

  1. #1
    Lounger
    Join Date
    Mar 2001
    Location
    AZ
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Macro

    In Word 97, we had so much trouble with "Same as Previous". One day in my troubleshooting I found a macro that took all of the "Same as Previous" out of the document. Does anyone know where I can locate that macro for Word 2000?

  2. #2
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Macro

    Meradel,

    The following macro should do this for you (and should work in both 97 and 2000 Word):

    <pre>Public Sub RemoveSameAsPrevious()
    Dim aSect As Section
    Dim aHdr As HeaderFooter
    Dim aFtr As HeaderFooter
    For Each aSect In ActiveDocument.Sections
    For Each aHdr In aSect.Headers
    aHdr.LinkToPrevious = False
    Next aHdr
    For Each aFtr In aSect.Footers
    aFtr.LinkToPrevious = False
    Next aFtr
    Next aSect
    End Sub
    </pre>

    Gary

  3. #3
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,049
    Thanks
    124
    Thanked 119 Times in 116 Posts

    Re: Macro

    Gary,

    With your permission, I would like to post this on my website (when it gets back up).
    Charles Kyle Kenyon
    Madison, Wisconsin

  4. #4
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Macro

    Hi Charles,

    Can't see any reason why not. Just give the Lounge, and me, a good plug. <img src=/S/laugh.gif border=0 alt=laugh width=15 height=15>

    Hope you're up and running again soon....

    Gary

  5. #5
    Lounger
    Join Date
    Mar 2001
    Location
    AZ
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro

    OK, Gary. I have to say "Uncle", I give up. I have been working with applications for years but my expertise in macros is confined to an occasional "record" and although I have books on the shelf, I have not learned how to paste in a macro. My questions are where to put it. I go to the VBA editor and get the Ask Main area. I pasted in the terminology and spaced it like you had it. Of course, there is an End Sub at the bottom and I am not sure if I should erase it because there is an End Sub on your instructions. I tried to name it, with no spaces etc. I saved it to Normal, and then set up a fake document with "Same As Previous" headers to test it. It would not run. I should have kept the error and sent the verbiage to you but I just erased the whole thing and would like to start over. Perhaps some hints in the right direction would be helpful. I feel really dumb asking for help on this but as I say, it has not been an area of study. It is on my list, but has never made it to the top since the need here is more fundamental.

  6. #6
    BAM
    Guest

    Re: Macro

    Hi Meradel,

    Copy all the lines from Gary's post between Sub and End Sub.

    For the line breaks to appear correctly in the code, in Word paste the lines in a Word document and then copy them again. (I got this wonderful tip from... Drat! I forget who, Geoff or Andrew maybe? Sorry for forgetting!)

    Then go Tools/Macro/Macros, type a name for the macro such as RemoveSameAsPrevious and click Create.

    Paste the lines of Code in between Sub and End Sub. And there you have your macro!
    ~~~~~~~~~~~~~~
    Cheers!

  7. #7
    Lounger
    Join Date
    Mar 2001
    Location
    AZ
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro

    Thank you so much. Your directions are very clear. I will try this.

  8. #8
    Lounger
    Join Date
    Mar 2001
    Location
    AZ
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro

    I am just getting back to this and I am getting a error saying ambiguous name.Here is what it says: It stops on the first line with an "Ambiguous Name Detected: RemoveSameAsPrevious."
    Sub RemoveSameAsPrevious()
    '
    ' RemoveSameAsPrevious Macro
    ' Macro created 7/17/2001 by phxmmr1
    '
    Public Sub RemoveSameAsPrevious()
    Dim aSect As Section
    Dim aHdr As HeaderFooter
    Dim aFtr As HeaderFooter
    For Each aSect In ActiveDocument.Sections
    For Each aHdr In aSect.Headers
    aHdr.LinkToPrevious = False
    Next aHdr
    For Each aFtr In aSect.Footers
    aFtr.LinkToPrevious = False
    Next aFtr
    Next aSect
    End Sub

    End Sub

  9. #9
    BAM
    Guest

    Re: Macro

    Hi Meradel,

    You just need to delete the first and last lines:

    Sub RemoveSameAsPrevious()
    and
    End Sub

    It was just a matter of copy/paste. I believe you copied all of the lines of the posted macro instead of just those between Sub and End Sub. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

    Sub... End Sub are the beginning and ending points of the macro and were already included in the code. When you used the method I provided, (Tools/Macro/Macros, type the macro name and click "Create") you created the Sub...End Sub for the macro. By including them again in the copy/paste it resulted in an ambiguous/duplicate error.
    ~~~~~~~~~~~~
    Cheers!

  10. #10
    Lounger
    Join Date
    Mar 2001
    Location
    AZ
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro

    It Works!!!!!!!!! Am I excited. Thank you so much. Everyone else here, who has to clean these corrupted documents thanks you!! Thanks to Gary for the Macro and BAM for the help getting it in correctly!

Posting Permissions

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