Results 1 to 13 of 13
  1. #1
    New Lounger
    Join Date
    Nov 2001
    Location
    Sydney, Australia, New South Wales, Australia
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Endnotes & Comments (97 SR2)

    1. Can someone provide a macro to strip all endnote references and endnote text from a file, as well as provide a toolbar button to run it (so the user just has to select the toolbar button)?
    We've got a form that uses endnotes to provide pop-up guidelines for each field, but the form gets sent to the customer and the 'powers that be' don't want the guidelines to be seen.

    2. Also one for removing all comments? I wanted to use comments instead of endnotes in the form because you can tell Word not to print comments, but the comment text still pop-up when the cursor is positioned at the reference.

    3. Is there any way to remove the coloured highlight from the comment reference insertion point?

    Thanks
    Mary Cahill
    mcahill4@csc.com.au

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Endnotes & Comments (97 SR2)

    These should work. I don't do toolbar buttons in code, so hopefully someone else can provide that, or you can find it in earlier posts in the Lounge.

    <pre>Sub RemoveEndnotes()
    If ActiveDocument.Endnotes.Count = 0 Then
    MsgBox "There are no endnotes to remove."
    Exit Sub
    End If
    If MsgBox("Remove all endnotes from this document?", _
    vbQuestion + vbYesNo) = vbNo Then Exit Sub
    Dim intCounter As Integer
    With ActiveDocument
    For intCounter = .Endnotes.Count To 1 Step -1
    .Endnotes(intCounter).Delete
    Next
    End With
    End Sub

    Sub RemoveComments()
    If ActiveDocument.Comments.Count = 0 Then
    MsgBox "There are no comments to remove."
    Exit Sub
    End If
    If MsgBox("Remove all comments from this document?", _
    vbQuestion + vbYesNo) = vbNo Then Exit Sub
    Dim intCounter As Integer
    With ActiveDocument
    For intCounter = .Comments.Count To 1 Step -1
    .Comments(intCounter).Delete
    Next
    End With
    End Sub</pre>


  3. #3
    New Lounger
    Join Date
    Nov 2001
    Location
    Sydney, Australia, New South Wales, Australia
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Endnotes & Comments (97 SR2)

    Wow - That was fast! Thank you and I can't wait to try it out (though I'm confident it will work because your stuff always does).

    When I create the macro, I know I have to save it attached to the file, but the file is not a true template (.dot). I haven't been able to convince the 'powers that be' that 'real' templates should be used instead of regular .doc files. This isn't the first organisation I've worked for that uses the term 'template' for files that aren't 'real templates'. The reason they don't want to use .dot files is that our users access the 'templates' from the intranet &/or Lotus Notes Repository and generally open them directly (instead of saving them to a directory and pointing their WorkGroup Templates location to that directory). We've had problems with macros not working when 'true templates' are opened directly from the intranet &/or Lotus Notes Repository.

    Therefore, will the macro still 'travel' with the file if it's attached to Normal.dot and to the file?

    Cheers and thanks again
    Mary Cahill

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Endnotes & Comments (97 SR2)

    Actually, I forget whether you could save macros in Word97 documents, but I think it was possible... It's probably best, however, to place it either in Normal.dot or in a global template in the startup folder (Tools|Options...|File Locations|Startup). That way, it will not have to be added to all documents. Also, it can be scary to recipients to receive documents that generate macro warnings, and antivirus software could intercept your messages on the receiving end. Because you are planning to circulate these outside the company, it would probably make things go more smoothly not to have them in the documents.

  5. #5
    New Lounger
    Join Date
    Nov 2001
    Location
    Sydney, Australia, New South Wales, Australia
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Endnotes & Comments (97 SR2)

    Thanks again for the much appreciated advice.
    Re saving the macro in Normal.dot - I wasn't sure if this meant it was only saved in my local Normal.dot or if it 'traveled' with the file and attached itself to everyone's Normal.dot.
    If I attach it to a global template in the startup folder it won't work for anyone else (am I right?) unless I distribute that template with instructions on how to add it to each person's startup folder. Our users aren't ready for this, so I think I'll try attaching it to Normal.dot and see how I go (I'll keep my fingers crossed re antivirus software intercepts).

    Thanks again for all your help
    Mary Cahill

  6. #6
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Endnotes & Comments (97 SR2)

    Sorry, I misread the question. Normal.dot also is personal to your computer, but you could create a global template that others in the company would use. This is much easier than explaining to everyone how to install a macro into their Normal.dot.

  7. #7
    New Lounger
    Join Date
    Nov 2001
    Location
    Sydney, Australia, New South Wales, Australia
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Endnotes & Comments (97 SR2)

    Thank you, the macro works fine and I've attached it to a toolbar button. One other request, please.

    I'd like to add a command at the end of this macro to delete the last section break. The file consists of three sections, and all endnotes are in section 3. Once the user runs the macro to delete all endnotes, they're left with a blank page at the end of the file. I'd like to remove this page and its section break. I've done this manually, and have been reminded of Word 97's wierd behaviour of applying the deleted section's page layout to the remaining section. My file has different margins in section 3 that affect the last table in section 2 when section 3 is deleted. So my macro commands need to apply the page margins of section 2 to section 3 BEFORE deleting section 3.

    Will someone please provide the macro commands than I can append to the end of the macro below -- Sub RemoveEndnotes()

    Thank you and eternally grateful
    Mary Cahill

  8. #8
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Endnotes & Comments (97 SR2)

    You might not need all of this, or you might need more. For general use, I added a bit of error checking. Hope this helps.

    <pre>Sub LastSectionPageSetup()
    ' Replicates various Page Setup parameters from the second-to-last
    ' section to the last section
    ' Jefferson Scher 2002-05-01

    'Check for multiple sections
    Dim intLastSection As Integer
    intLastSection = ActiveDocument.Sections.Count
    If intLastSection = 1 Then
    MsgBox "You do not need to do this."
    Exit Sub
    End If

    'Get informed consent before operating
    If MsgBox("Reset page setup for last section in preparation for deleting " & _
    "section break?", vbQuestion + vbYesNo) = vbNo Then Exit Sub

    'Change various properties...this could go on and on!
    Dim sectLast As Section, sectNextToLast As Section
    Set sectLast = ActiveDocument.Sections(intLastSection)
    Set sectNextToLast = ActiveDocument.Sections(intLastSection - 1)
    With sectLast.PageSetup
    .Orientation = sectNextToLast.PageSetup.Orientation
    .TopMargin = sectNextToLast.PageSetup.TopMargin
    .BottomMargin = sectNextToLast.PageSetup.BottomMargin
    .LeftMargin = sectNextToLast.PageSetup.LeftMargin
    .RightMargin = sectNextToLast.PageSetup.RightMargin
    .HeaderDistance = sectNextToLast.PageSetup.HeaderDistance
    .FooterDistance = sectNextToLast.PageSetup.FooterDistance
    End With
    Set sectNextToLast = Nothing
    Set sectLast = Nothing
    MsgBox "Page orientation and margins reset."
    End Sub</pre>

    It probably makes sense to check the nature of the section break (e.g., new page vs. continuous), but... that's a bit beyond the current mission.

  9. #9
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Endnotes & Comments (97 SR2)

    It would probably be helpful to set the .LinkToPrevious property of all the headers and footers in the last section as well, this way you wouldn't need to copy any header or footer text.

    StuartR

  10. #10
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Endnotes & Comments (97 SR2)

    If I ever get around to building a general purpose SectionAttributeCopy procedure, I'll copy all the headers and footers one by one (using a loop, of course). Whether to LinkToPrevious or not, hmmm, I'll have to think about that. Should it be the same as what was set in the NextToLast, or...

  11. #11
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Endnotes & Comments (97 SR2)

    I confused myself when thinking about it.

    I think that the easiest way to copy the headers is probably something like

    For each header or footer in last section
    LinkToPrevious = True
    Next

    For each header or footer in next to last section
    If not LinkToPrevious then (LinkToPrevious in corresponding header or footer of last section) = False
    Next

    I think that this will copy all headers from the next to last section break to the last one, but I'm starting to get very confused <img src=/S/confused.gif border=0 alt=confused width=15 height=20>

    StuartR

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

    Re: Endnotes & Comments (97 SR2)

    It's a shame there isn't some programatic way to take advantage of the tip for doing it interactively, which Phil Rabichow posted here some time ago:

    Go to second to last section. Click on File > Page Setup. When the Page Setup dialog shows, click on OK.
    Go to the last section and simply click on F4 to repeat the action (there's another key combination for RepeatAction; someone will have to refresh my memory).
    Amazingly, all of the page setup for the second to last section is now applied to the last section, and the section break between them can simply be deleted. <img src=/S/trophy.gif border=0 alt=trophy width=15 height=15>

    The closest I could get to this via code was this, but it doesn't work:

    <pre>Public Sub ReproduceSectionFormatting()
    Dim lngSectCt As Long
    lngSectCt = ActiveDocument.Sections.Count
    Selection.HomeKey Unit:=wdStory
    'Go to second to last section:
    Selection.GoTo What:=wdGoToSection, Which:=wdGoToFirst, _
    Count:=lngSectCt - 1, Name:=""
    'Display the PageSetup dialog (for a split second) (.Execute doesn't work either):
    Dialogs(wdDialogFilePageSetup).Display 1
    'Go to last section:
    Selection.GoTo What:=wdGoToSection, Which:=wdGoToFirst, _
    Count:=lngSectCt, Name:=""
    Application.Repeat
    End Sub
    </pre>


    possibly this is not working because the Application.Repeat is repeating the 'go to last section'!

    - btw a warning appears needed re the use of 'Application.Repeat' - after running this code, the F4 keystroke no longer works in the current Word session! - have to quit and restart Word to get it working again.....weird.

    Gary

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

    Re: Endnotes & Comments (97 SR2)

    SendKeys - the last refuge of the desperate programmer! - however, the following code does appear to reproduce Phil's magic trick:

    <pre>Public Sub ReproduceSectionFormatting()
    Dim lngSectCt As Long
    lngSectCt = ActiveDocument.Sections.Count
    Selection.HomeKey Unit:=wdStory
    'Go to second to last section:
    Selection.GoTo What:=wdGoToSection, Which:=wdGoToFirst, _
    Count:=lngSectCt - 1, Name:=""
    'Execute page setup dialog without showing it:
    Dialogs(wdDialogFilePageSetup).Execute
    'Go to last section:
    Selection.EndKey Unit:=wdStory
    SendKeys "{F4}"
    End Sub
    </pre>

    Gary

Posting Permissions

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