+ Reply to Thread
Results 1 to 6 of 6

Find and replace as footnote (from Excel)

  1. #1
    Registered User
    Join Date
    06-28-2011
    Location
    Bristol, UK
    MS-Off Ver
    Excel 2010, 2013, 2016, 365
    Posts
    79

    Exclamation Find and replace as footnote (from Excel)

    Hi All,

    I have an Excel routine that populates a Word template by searching codes and replacing them with the relevant text. This is working fine.

    Embedded within the replacement text, I have additional codes that relate to footnotes - the Excel tool can correctly identify these codes, look up the relevant footnote text and add a new footnote with the correct reference and text. All good.

    What I cannot get it to successfully do is place the footnote at the correct location in the body of the Word document. Currently, my best solution is as follows:

    Please Login or Register  to view this content.
    The problem is in correctly defining the location of the SearchCode within the body of the document - using the InStr() function doesn't work because this picks up all the nonprintable characters in the document, so the character count is never correct.

    Any suggestions for how to get around this? Perhaps one of the following:
    • Is there some way of me defining Rge in terms of an output from the .Find function?
    • Alternatively, can I replace the SearchCode directly with the footnote?
    • Or, instead, is there a simple way of identifying the accurate character count / insertion point for the replaced text?

    Many thanks in advance,
    AL

  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: Find and replace as footnote (from Excel)

    Try:
    Please Login or Register  to view this content.
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Registered User
    Join Date
    06-28-2011
    Location
    Bristol, UK
    MS-Off Ver
    Excel 2010, 2013, 2016, 365
    Posts
    79

    Re: Find and replace as footnote (from Excel)

    No, that doesn't work - just errors out...

    Thanks though.

  4. #4
    Registered User
    Join Date
    06-28-2011
    Location
    Bristol, UK
    MS-Off Ver
    Excel 2010, 2013, 2016, 365
    Posts
    79

    Re: Find and replace as footnote (from Excel)

    Just an update - I still haven't resolved this issue but I think i understand why it isn't working.

    Please Login or Register  to view this content.
    According to other sources, if this were being written in Word VBA (rather than via Excel), the Rge variable would actually be set as a Range, rather than as an object. At point [1] in the code, the scope of the Rge variable would then be redefined to start at the location of the found text.

    This is not happening when the Object vartype is used, and i can't find any way of getting the Find function to return to the position of the found text.

    Any ideas on how to do this from Excel?

  5. #5
    Registered User
    Join Date
    06-28-2011
    Location
    Bristol, UK
    MS-Off Ver
    Excel 2010, 2013, 2016, 365
    Posts
    79

    Re: Find and replace as footnote (from Excel)

    Solved.

    I think it was something to do with my use of braces {} - when I stop searching for a code bracketed in braces (e.g. "{1}") and switch instead to searching for a unique string ("REF01"), the Rge object correctly readjusts its scope and I can use that.

    Weird.

    Final code:
    Please Login or Register  to view this content.
    (Not: I have retained the braces around the unique code, hence needing to adjust the size of Rge at the end. When they are included in the search, the Find function doesn't adjust the scope of Rge.)

  6. #6
    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: Find and replace as footnote (from Excel)

    The code I posted works just fine for the scenario you described in post #1. If it's not working for you, that's because your content is not what you described. As for erroring out, that suggests you're not even using the code as posted...

+ 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] How do I place a footnote in an Excel cell?
    By janw in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-15-2022, 11:28 AM
  2. Replies: 16
    Last Post: 12-02-2014, 03:38 PM
  3. Replies: 3
    Last Post: 11-25-2014, 06:08 AM
  4. find in excel replace in word: find/replace text in text boxes and headers
    By dean.rogers in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-10-2012, 12:40 PM
  5. Adding footnote to cell in Excel
    By Tom B in forum Excel General
    Replies: 1
    Last Post: 02-17-2006, 05:35 PM
  6. [SOLVED] Insert a footnote or endnote in Excel
    By John in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-03-2006, 11:00 AM
  7. How do I put a footnote on to one page only in Excel?
    By mejulie9 in forum Excel General
    Replies: 1
    Last Post: 07-06-2005, 11:05 AM

Tags for this Thread

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