Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Formats > Workshop

Notices

Reply
 
Thread Tools Search this Thread
Old 09-05-2008, 12:37 PM   #1
Hadrien
Feedbooks.com Co-Founder
Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.
 
Hadrien's Avatar
 
Posts: 2,265
Karma: 145123
Join Date: Nov 2006
Location: Paris, France
Device: Sony PRS-t-1/350/300/500/505/600/700, Nexus S, iPad
Word Macro: Footnotes to inline text ?

I know that we've got some level 100 Word ninjas on this forum, with far better macro skills than I have (I haven't mastered this ninja art in its most basic form yet).

A common thing that I need to do while pre-processing e-books is to transform footnotes into inline text. A footnote in Word is actually separated into 2 different things:
  • the footnote mark
  • the text of the footnote
I'd like to replace the mark and get something like <span class="footnote">Text</span>. This mean that I would have to iterate through footnotes, grab the text and replace the mark with the text.

Any one with enough Word macro ninja skills to help me on this one ? I really need to level up, but I'm kinda stuck with this one
Hadrien is offline   Reply With Quote
Old 09-05-2008, 04:21 PM   #2
=X=
Wizard
=X= ought to be getting tired of karma fortunes by now.=X= ought to be getting tired of karma fortunes by now.=X= ought to be getting tired of karma fortunes by now.=X= ought to be getting tired of karma fortunes by now.=X= ought to be getting tired of karma fortunes by now.=X= ought to be getting tired of karma fortunes by now.=X= ought to be getting tired of karma fortunes by now.=X= ought to be getting tired of karma fortunes by now.=X= ought to be getting tired of karma fortunes by now.=X= ought to be getting tired of karma fortunes by now.=X= ought to be getting tired of karma fortunes by now.
 
=X='s Avatar
 
Posts: 3,672
Karma: 12205348
Join Date: Mar 2008
Device: Galaxy S, Nook w/CM7
Hi Hadrien,
Try this, see code comments proceeded with ' for descriptions
=X=

Code:
Dim oFeets As Footnotes
Dim oFoot As Footnote
Dim oRange As Range
Dim szFootNoteText As String

' Grabs the collection of FootNotes
Set oFeets = Word.ActiveDocument.Footnotes

' Iterates through each footnote
For Each oFoot In oFeets
    
    'See the footnote text
    MsgBox oFoot.Range.Text
    
    szFootNoteText = oFoot.Range.Text
    
    'Start search from beginning of document
    Selection.HomeKey Unit:=wdStory
    Selection.Find.ClearFormatting
    
    With Selection.Find
        .Text = "^f" ' Looks for all footnotes
        .Forward = True
        .Wrap = wdFindStop
    End With
    
    Selection.Find.Execute
    ' Delete the footnote
    oFoot.Delete
    
    'Insert the footnote text
    'Here you do whatever format tickles your fancy
    Selection.Text = "<" + szFootNoteText + ">"
    Selection.InsertParagraphBefore
    Selection.InsertParagraphAfter
    Selection.Font.Bold = wdToggle
Next

Last edited by =X=; 09-05-2008 at 04:22 PM. Reason: Fixed typos
=X= is offline   Reply With Quote
Old 09-05-2008, 05:51 PM   #3
Hadrien
Feedbooks.com Co-Founder
Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.
 
Hadrien's Avatar
 
Posts: 2,265
Karma: 145123
Join Date: Nov 2006
Location: Paris, France
Device: Sony PRS-t-1/350/300/500/505/600/700, Nexus S, iPad
Thanks, it seems to be working very well. So basically while the footnote marks (^f) can be found like a paragraph (^p), the footnotes themselves are a style for Word ? That's the main reason why I couldn't find a way to do this....
Hadrien is offline   Reply With Quote
Old 09-06-2008, 03:13 AM   #4
=X=
Wizard
=X= ought to be getting tired of karma fortunes by now.=X= ought to be getting tired of karma fortunes by now.=X= ought to be getting tired of karma fortunes by now.=X= ought to be getting tired of karma fortunes by now.=X= ought to be getting tired of karma fortunes by now.=X= ought to be getting tired of karma fortunes by now.=X= ought to be getting tired of karma fortunes by now.=X= ought to be getting tired of karma fortunes by now.=X= ought to be getting tired of karma fortunes by now.=X= ought to be getting tired of karma fortunes by now.=X= ought to be getting tired of karma fortunes by now.
 
=X='s Avatar
 
Posts: 3,672
Karma: 12205348
Join Date: Mar 2008
Device: Galaxy S, Nook w/CM7
Quote:
Originally Posted by Hadrien View Post
Thanks, it seems to be working very well. So basically while the footnote marks (^f) can be found like a paragraph (^p), the footnotes themselves are a style for Word ? That's the main reason why I couldn't find a way to do this....
Kind of, but footnotes are not styles they are objects.The closet analogy I can give you is that a word document is very much like a DOM object for XML. Footnotes are collections (elements) and a Footnote is an object (element). You have to get the collections of footnotes form the document (DOM) object. But to find out where the footnotes are located (what node) you have to search through the document (DOM) structure. The collection identifier is a (^f) key.

What was weird is that Footnotes seem to be tables, so to get the text one had to use the Range object to get the textual information.

=X=
=X= is offline   Reply With Quote
Old 09-13-2008, 11:30 AM   #5
HarryT
eBook Enthusiast
HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.
 
HarryT's Avatar
 
Posts: 62,099
Karma: 39287007
Join Date: Nov 2006
Location: UK
Device: PW2, iPad Retina Mini, iPhone 4, MS Surface Pro, Onyx T68, N7,
Why do you want to convert footnotes into inline text? Isn't it better to have them as endnotes in an eBook? That's what I always do myself.
HarryT is offline   Reply With Quote
Old 09-13-2008, 11:34 AM   #6
zelda_pinwheel
zeldinha zippy zeldissima
zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.zelda_pinwheel ought to be getting tired of karma fortunes by now.
 
zelda_pinwheel's Avatar
 
Posts: 27,828
Karma: 908606
Join Date: Dec 2007
Location: Paris, France
Device: eb1150 & is that a nook in her pocket, or she just happy to see you?
Quote:
Originally Posted by HarryT View Post
Why do you want to convert footnotes into inline text? Isn't it better to have them as endnotes in an eBook? That's what I always do myself.
personally i prefere inline notes so far. it's still a lot of button pressing to get to the notes and i always read them, and when there are a lot i've found this gets tedious on a cybook (on my eb1150, on the other hand, with touchscreen and hyperlink ability, it's easy and pleasant. just saying.). they can easily be distinguished from the main text in many ways (an hr rule before and after, slightly reduced text size, indent...).

luckily, epub will be able to support TRUE footnotes, at the foot of the page, despite the reflowable text. won't THAT be nice.
zelda_pinwheel is offline   Reply With Quote
Old 09-13-2008, 11:39 AM   #7
Hadrien
Feedbooks.com Co-Founder
Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.
 
Hadrien's Avatar
 
Posts: 2,265
Karma: 145123
Join Date: Nov 2006
Location: Paris, France
Device: Sony PRS-t-1/350/300/500/505/600/700, Nexus S, iPad
Quote:
Originally Posted by HarryT View Post
Why do you want to convert footnotes into inline text? Isn't it better to have them as endnotes in an eBook? That's what I always do myself.
I want to mark them in a way that I can use to do anything. Currently on Feedbooks we do real footnotes for PDF, inline notes for Mobipocket & ePub. I'll change this behavior to end notes for Mobipocket & ePub in the upcoming weeks. And once ePub finally get true footnotes, I'll switch it to true footnotes.

The good part is that I won't have to manually process all the files. Since I've marked them correctly as footnotes (and not just a link to an anchor), I can process them the way that I want.
Hadrien is offline   Reply With Quote
Old 09-13-2008, 11:41 AM   #8
HarryT
eBook Enthusiast
HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.
 
HarryT's Avatar
 
Posts: 62,099
Karma: 39287007
Join Date: Nov 2006
Location: UK
Device: PW2, iPad Retina Mini, iPhone 4, MS Surface Pro, Onyx T68, N7,
Quote:
Originally Posted by zelda_pinwheel View Post
personally i prefere inline notes so far. it's still a lot of button pressing to get to the notes and i always read them, and when there are a lot i've found this gets tedious on a cybook (on my eb1150, on the other hand, with touchscreen and hyperlink ability, it's easy and pleasant. just saying.). they can easily be distinguished from the main text in many ways (an hr rule before and after, slightly reduced text size, indent...).
But if the notes are long and/or numerous, they can interfere with the flow of the text. Eg, the wonderful Penguin eBook of Jane Austen's "Pride and Prejudice" (an example to every publisher of how to produce a good eBook) has many notes in each chapter, and many of them are long. If I'm reading it, I wouldn't look up a note on what a "chaise and four" is, because I know what it is, and I wouldn't want to see the half page of text on it in the middle of the main text either.

In the case of this particular book, by the way, even in the printed book the notes are endnotes, not footnotes. If you have a few words, a footnote is fine, but if you have a page of explanatory text, an endnote works a lot better.
HarryT is offline   Reply With Quote
Old 09-13-2008, 11:41 AM   #9
HarryT
eBook Enthusiast
HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.
 
HarryT's Avatar
 
Posts: 62,099
Karma: 39287007
Join Date: Nov 2006
Location: UK
Device: PW2, iPad Retina Mini, iPhone 4, MS Surface Pro, Onyx T68, N7,
Quote:
Originally Posted by Hadrien View Post
I want to mark them in a way that I can use to do anything. Currently on Feedbooks we do real footnotes for PDF, inline notes for Mobipocket & ePub. I'll change this behavior to end notes for Mobipocket & ePub in the upcoming weeks. And once ePub finally get true footnotes, I'll switch it to true footnotes.

The good part is that I won't have to manually process all the files. Since I've marked them correctly as footnotes (and not just a link to an anchor), I can process them the way that I want.
That sound good - thanks!
HarryT is offline   Reply With Quote
Old 09-13-2008, 11:44 AM   #10
Hadrien
Feedbooks.com Co-Founder
Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.
 
Hadrien's Avatar
 
Posts: 2,265
Karma: 145123
Join Date: Nov 2006
Location: Paris, France
Device: Sony PRS-t-1/350/300/500/505/600/700, Nexus S, iPad
Quote:
Originally Posted by HarryT View Post
But if the notes are long and/or numerous, they can interfere with the flow of the text. Eg, the wonderful Penguin eBook of Jane Austen's "Pride and Prejudice" (an example to every publisher of how to produce a good eBook) has many notes in each chapter, and many of them are long. If I'm reading it, I wouldn't look up a note on what a "chaise and four" is, because I know what it is, and I wouldn't want to see the half page of text on it in the middle of the main text either.

In the case of this particular book, by the way, even in the printed book the notes are endnotes, not footnotes. If you have a few words, a footnote is fine, but if you have a page of explanatory text, an endnote works a lot better.
Sure and I intend to add both a footnote and endnote button to our interface in the future (currently we only have the footnote button). Based on the output format, each will behave differently.
Hadrien is offline   Reply With Quote
Old 09-13-2008, 11:49 AM   #11
HarryT
eBook Enthusiast
HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.
 
HarryT's Avatar
 
Posts: 62,099
Karma: 39287007
Join Date: Nov 2006
Location: UK
Device: PW2, iPad Retina Mini, iPhone 4, MS Surface Pro, Onyx T68, N7,
Even better!
HarryT is offline   Reply With Quote
Old 09-13-2008, 11:54 AM   #12
tompe
Grand Sorcerer
tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.tompe ought to be getting tired of karma fortunes by now.
 
Posts: 6,966
Karma: 3454321
Join Date: Oct 2007
Location: Linköpng, Sweden
Device: Nexus 7, Nexus 4, iPad 2, Notion Ink Adam Qi, Kindle WiFi, Kindle PW
Quote:
Originally Posted by Hadrien View Post
Sure and I intend to add both a footnote and endnote button to our interface in the future (currently we only have the footnote button). Based on the output format, each will behave differently.
And could you also add a back link from the footnote to the place in the text it refer to. That is something I really miss in paper books and an obvious thing to have in an ebook.
tompe is offline   Reply With Quote
Old 09-13-2008, 12:04 PM   #13
Hadrien
Feedbooks.com Co-Founder
Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.
 
Hadrien's Avatar
 
Posts: 2,265
Karma: 145123
Join Date: Nov 2006
Location: Paris, France
Device: Sony PRS-t-1/350/300/500/505/600/700, Nexus S, iPad
Quote:
Originally Posted by tompe View Post
And could you also add a back link from the footnote to the place in the text it refer to. That is something I really miss in paper books and an obvious thing to have in an ebook.
Sure, should be very easy in Mobipocket & PDF, probably a little more difficult in ePub with the multiple flows, but possible anyway.
Hadrien is offline   Reply With Quote
Old 09-13-2008, 12:57 PM   #14
Sparrow
Wizard
Sparrow ought to be getting tired of karma fortunes by now.Sparrow ought to be getting tired of karma fortunes by now.Sparrow ought to be getting tired of karma fortunes by now.Sparrow ought to be getting tired of karma fortunes by now.Sparrow ought to be getting tired of karma fortunes by now.Sparrow ought to be getting tired of karma fortunes by now.Sparrow ought to be getting tired of karma fortunes by now.Sparrow ought to be getting tired of karma fortunes by now.Sparrow ought to be getting tired of karma fortunes by now.Sparrow ought to be getting tired of karma fortunes by now.Sparrow ought to be getting tired of karma fortunes by now.
 
Posts: 4,400
Karma: 1358102
Join Date: Nov 2007
Location: UK
Device: Palm TX, CyBook Gen3
Quote:
Originally Posted by HarryT View Post
But if the notes are long and/or numerous, they can interfere with the flow of the text.
I prefer inline notes because I find them less disruptive than constantly flipping back and forward.

Quote:
Originally Posted by HarryT View Post
Eg, the wonderful Penguin eBook of Jane Austen's "Pride and Prejudice" (an example to every publisher of how to produce a good eBook) has many notes in each chapter, and many of them are long. If I'm reading it, I wouldn't look up a note on what a "chaise and four" is, because I know what it is, and I wouldn't want to see the half page of text on it in the middle of the main text either.
I always tend to read the notes. I've a vague idea what a "chaise and four" is, but a note could also expand on other topics; e.g. it's social significance at the time the story is set. If the note is half a page long, it's likely to tell me something I didn't know - if I assumed I didn't need to refer to the note; and it's hidden, unseen, at the back of the book, I'd be missing out.
Sparrow is offline   Reply With Quote
Old 09-13-2008, 01:05 PM   #15
Hadrien
Feedbooks.com Co-Founder
Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.Hadrien understands the importance of being earnest.
 
Hadrien's Avatar
 
Posts: 2,265
Karma: 145123
Join Date: Nov 2006
Location: Paris, France
Device: Sony PRS-t-1/350/300/500/505/600/700, Nexus S, iPad
Quote:
Originally Posted by Sparrow View Post
I always tend to read the notes. I've a vague idea what a "chaise and four" is, but a note could also expand on other topics; e.g. it's social significance at the time the story is set. If the note is half a page long, it's likely to tell me something I didn't know - if I assumed I didn't need to refer to the note; and it's hidden, unseen, at the back of the book, I'd be missing out.
I've read a study about notes some months ago. It stated that most people read footnotes, which is not the case with endnotes. 9 out of 10 people will also read the footnote before the text where they're anchored.
Hadrien is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Word Formatting Macro (Stingo's Macro) Stingo Sony Reader 75 08-24-2010 05:18 AM
inline page markers overtop of text?? Stinger Kobo Reader 9 05-28-2010 05:42 PM
Calibre email inline text? squawker Calibre 2 05-26-2010 06:17 PM
need vba/word scripting help to turn inline text into header Bierkonig Workshop 3 01-09-2009 09:40 PM
Reformatting untidy text files macro 46137 Workshop 8 05-02-2008 09:27 PM


All times are GMT -4. The time now is 01:42 AM.


MobileRead.com is a privately owned, operated and funded community.