+ Reply to Thread
Results 1 to 9 of 9

deleting word bookmarks from excel - change to existing code

  1. #1
    Registered User
    Join Date
    08-10-2017
    Location
    london
    MS-Off Ver
    2016
    Posts
    8

    deleting word bookmarks from excel - change to existing code

    Hi,

    I have some code which is working perfectly within excel to paste data into word. I'm now just looking to add deletion of bookmarks at the end of the code, so the last process undertaken after the data has been pushed into word is that the bookmarks are deleted (Not the text, just the reference point).

    I've found some bookmark deletion code which works in word (and it keeps the text) and done some researching but can't find how to add it and get it working. Hopefully this will be an easy one for your expert standards!

    Any help greatly appreciated.

    Please Login or Register  to view this content.
    and here is the bookmark deletion code that deletes the bookmark but not the text

    Please Login or Register  to view this content.
    Last edited by excelor100; 08-14-2017 at 07:30 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: deleting word bookmarks from excel - change to existing code

    I'm not sure how to get excel to recognize bookmarks, but if putting a macro in your word doc is an option, you could add this code in your macro
    Please Login or Register  to view this content.
    where "Test" would be a macro in your word doc corresponding to
    Please Login or Register  to view this content.

  3. #3
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: deleting word bookmarks from excel - change to existing code

    Maybe:

    Please Login or Register  to view this content.
    Last edited by xladept; 08-14-2017 at 11:44 AM. Reason: Corrected for working code
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  4. #4
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: deleting word bookmarks from excel - change to existing code

    @xladept,

    It appears that the code is late bound, so you need to declare the variable as Object
    Please Login or Register  to view this content.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  5. #5
    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: deleting word bookmarks from excel - change to existing code

    Is there a particular reason you need to delete the bookmarks? Empty bookmarks, for example, are of no consequence (and that's precisely what yours remain). Do note, too, that any cross-references to other bookmarks you may have will generate errors if their bookmarks get deleted...
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  6. #6
    Registered User
    Join Date
    08-10-2017
    Location
    london
    MS-Off Ver
    2016
    Posts
    8

    Re: deleting word bookmarks from excel - change to existing code

    @xladept and xlnitwit - thanks for your responses. I have tried the code Xladept but I get the error 'user-defined type not defined'

    @xlnitwit - I changed the declaration of the viarable as you stated
    Please Login or Register  to view this content.
    but then I get error no.438.

    If you get the chance to look over it again, would be hugely grateful.

    As I mentioned the original code I pasted works perfectly and does exactly what I want, other than delete the bookmarks at the end.

    I am able to run a separate macro in word to get rid of the bookmarks (the one I posted), but then that requires manual intervention which obviously I want to avoid using the macro.

    Thanks!

  7. #7
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: deleting word bookmarks from excel - change to existing code

    Change the loop to read thus
    Please Login or Register  to view this content.
    I would also second macropod's comment.

  8. #8
    Registered User
    Join Date
    08-10-2017
    Location
    london
    MS-Off Ver
    2016
    Posts
    8

    Re: deleting word bookmarks from excel - change to existing code

    @danielexcelvba - thanks for taking the time to reply, I have a word macro already which I used to test the concept of deleting word bookmarks (but not the text), but thank you!

    @macropod - yes there is a particular reason, being the person who will get the final document does not like bookmarks so it's a top secret mission so to speak

  9. #9
    Registered User
    Join Date
    08-10-2017
    Location
    london
    MS-Off Ver
    2016
    Posts
    8

    Re: deleting word bookmarks from excel - change to existing code

    Quote Originally Posted by xlnitwit View Post
    Change the loop to read thus
    Please Login or Register  to view this content.
    I would also second macropod's comment.
    That works perfectly thank you!

    Really appreciate your time and everyone else's to assist me.

    Hopefully you saw my reply to macropod, I am aware I can just amend the word document so the bookmarks are not showing, but in this case the recipient does not want bookmarks to be used for their documents. Although there is no issue in me using them. This way I can send the document without manually deleting each one.

+ 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. [SOLVED] Copy from Excel to Word Bookmarks
    By julhs in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-07-2016, 12:34 PM
  2. VBA Transfer Data From Excel to Word and Keep Bookmarks in Word Documents
    By ShakJames in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-08-2015, 05:37 AM
  3. vba code to delete the empty bookmarks in Word document
    By mvneema in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-18-2014, 08:29 AM
  4. Consolidating bookmarks in word into excel
    By kchm_2000 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-15-2012, 11:08 AM
  5. Excel to Word passing data dynamically with bookmarks from Excel to Word
    By csekhar.apps in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-10-2010, 09:52 AM
  6. Excel and Word Bookmarks
    By JFamilo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-14-2005, 01:05 AM
  7. [SOLVED] VBA, Bookmarks, Word and Excel... help please!
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-13-2005, 05:06 PM

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