+ Reply to Thread
Results 1 to 4 of 4

Delete bookmark AND trailing paragraphs

  1. #1
    Registered User
    Join Date
    11-09-2016
    Location
    London, England
    MS-Off Ver
    2010/2016
    Posts
    68

    Delete bookmark AND trailing paragraphs

    Hi,

    Take a template like this:

    [Bookmark1]

    [Bookmark2]

    [Bookmark3]

    [Bookmark4]

    [Bookmark5]


    If I do this in VBA:

    Please Login or Register  to view this content.
    The line gets deleted but the pagraphs that follow remain. I know I could include the paragraphs inside the bookmark but I am not just deleting them. If there is a value from a data source, the bookmark gets replaced with the value, and that would include the paragraphs so you end up:

    [Bookmark1][Bookmark2]

    I could then include paragraph marks in the returned value from the database but then it all gets messy!

    So given the example template, can I do someting like this:

    Please Login or Register  to view this content.

    Thanks

  2. #2
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Delete bookmark AND trailing paragraphs

    It seems to me you're going about this entirely the wrong way; you should consider using either: nested bookmarks so you can delete the outer range if the inner one isn't to be populated; or field coding to conditionally show/hide the related content.
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Registered User
    Join Date
    11-09-2016
    Location
    London, England
    MS-Off Ver
    2010/2016
    Posts
    68

    Re: Delete bookmark AND trailing paragraphs

    Maybe it was wrong of me, but although this is a Word thing (bookmarks, fields etc.) this is a requirement in Outlook (using Word as editor).

    Fields don't seem to be available there. This is what I've got so far (I know it doesn't take account of more than 2 paragraphs:

    Please Login or Register  to view this content.

  4. #4
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Delete bookmark AND trailing paragraphs

    The fact you're using Word as an Outlook editor makes no difference. If you bookmark a boilerplate range, e.g.:
    [Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna.]
    as BookmarkA, then, within that, insert another bookmark (BookmarkB), thus:
    [[BookmarkB] Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna.]
    you now have the choice of populating BookmarkB or deleting everything spanned by BookmarkA (via ActiveDocument.Bookmarks("BookmarkA").Range.Delete).

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Delete 4 separate paragraphs
    By jr01245 in forum Word Programming / VBA / Macros
    Replies: 1
    Last Post: 08-10-2016, 12:27 PM
  2. [SOLVED] VBA Code to delete trailing spaces:
    By Chad Bateman in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-28-2015, 05:56 PM
  3. Delete all paragraphs containing a particular image using a VBA macro in MS Word
    By sshishirkumar in forum Word Programming / VBA / Macros
    Replies: 1
    Last Post: 09-30-2013, 07:06 PM
  4. [SOLVED] Delete trailing zeros.
    By krasher in forum Excel - New Users/Basics
    Replies: 8
    Last Post: 09-21-2012, 10:43 AM
  5. Delete trailing spaces & characters
    By bigband1 in forum Excel General
    Replies: 2
    Last Post: 03-06-2012, 04:24 PM
  6. Replies: 1
    Last Post: 09-30-2011, 06:00 AM
  7. Delete leading and trailing periods
    By evildave in forum Excel General
    Replies: 6
    Last Post: 06-04-2009, 11:02 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1