#16
|
|||
|
|||
If I may come back to this old topic: I'm trying it out right now. I'm looking for a more specific string of text.
But when I try to execute the macro, it gives me an error 5560, and error detection (or whatever it's called in English) highlights this line for me: Do While .Execute = True What could be wrong with that? I've modified the macro to look like this, to search for the texts I'd like to change into endnotes (i.e. texts like [EINDNOOT 1], where only the figure ever changes. (I'd really appreciate any help -- it's to get Word to fix a faulty manual notation for endnotes, where both me and the source text of my translation made some errors in the numbering. I hope converting the manual notations to real Word endnotes will fix the numbering. I can always convert back to plain text if need be -- I hope.) Quote:
(I can do some stuff with search and replace and macros, but I don't know enough about Word's macro language to understand all of the codes in this macro.) |
#17
|
||||
|
||||
Your Find expression is malformed, instead of:
"\[EINDNOOT [0-9]{1;3}(\]" you should have: "\[EINDNOOT [0-9]{1;3}\]" or "\[EINDNOOT [0-9]{1;3}(\])" Even then, however, the code won't work as the MID expression (in Mid(RngFnd.Text, 2, Len(RngFnd.Text) - 2)) would need to be modified to take account of your additional text. There is a more sophisticated version of the macro, that can deal with your [EINDNOOT #] format, here: http://gregmaxey.com/word_tip_pages/...footnotes.html
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#18
|
|||
|
|||
Thanks a lot. That was very sloppy of me.
In the meantime, I *have* got the original macro working, even with my EINDNOOT text in between the brackets. As far as I'm aware it worked fine in this form: Code:
Sub MakeEndNotes() Dim RngSel As Range, RngFnd As Range, StrNote As String Application.ScreenUpdating = False With Selection Set RngSel = .Range With .Find .ClearFormatting .Replacement.ClearFormatting .MatchWildcards = True .Wrap = wdFindContinue .Forward = True .Text = "\[EINDNOOT ([0-9]{1;3})\]" Do While .Execute = True Set RngFnd = ActiveDocument.Range(Start:=Selection.Start, End:=Selection.End) StrNote = Mid(RngFnd.Text, 2, Len(RngFnd.Text) - 2) ActiveDocument.Endnotes.Add RngFnd, , StrNote RngFnd.Text = vbNullString Loop End With End With RngSel.Select Set RngFnd = Nothing: Set RngSel = Nothing Application.ScreenUpdating = True End Sub And since that also stalls on my Word, for the moment I'll stick to this one. (And try to be a little cleverer in how I add endnote indications in my text, so they're easier to search & replace or convert into real endnotes and back.) Thanks anyway. Great that this thread is here for reference' sake. |
#19
|
|||
|
|||
255 Character Limit
Hi Paul,
I used the endnote demo and it works perfectly to extract the endnotes from the inline texts. However if the characters in each inline citation greater than 255 Character the endnote is not working. is there a way to bypass the 255 character limitation? |
#20
|
||||
|
||||
It looks like the ActiveDocument.Endnotes.Add command can take a Variant instead of a string. Try passing in the RngFnd range instead of converting that to a string and then passing that to the Endnotes.Add command.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#21
|
|||
|
|||
255 Character Limit
Hi Andrew,
Is this the way to do it? ActiveDocument.Endnotes.Add Range:=myRange, |
#22
|
|||
|
|||
Hi macropod,
I have seen your code here and on stackoverflow, but I'm unable to apply it. I created a macro using Visual Basic in Word and copied/pasted the code there. When I hit run, nothing happened. Could you please show me how to use the code? Thanks in advance! |
#23
|
||||
|
||||
For PC macro installation & usage instructions, see: Installing Macros
For Mac macro installation & usage instructions, see: Word:mac - Install a Macro
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#24
|
|||
|
|||
Quote:
Sub Convert () Do While .Find .Selection = "\{[!\{]@\}" Selection.Cut With Selection With .EndnoteOptions .Location = wdEndOfDocument .NumberingRule = wdRestartContinuous .StartingNumber = 1 .NumberStyle = wdNoteNumberStyleArabic End With .Endnotes.Add Range:=Selection.Range, Reference:="" End With Selection.Paste Loop End Sub |
#25
|
||||
|
||||
Try:
Code:
Sub MakeEndNotes() Application.ScreenUpdating = False Dim eNt As Endnote With ActiveDocument.Range With .Find .ClearFormatting .Replacement.ClearFormatting .MatchWildcards = True .Forward = True .Format = False .Wrap = wdFindStop .Text = "\{[!\{]@\}" End With Do While .Find.Execute = True .Characters.First.Text = vbNullString .Characters.Last.Text = vbNullString Set eNt = .Endnotes.Add(Range:=.Duplicate, Text:="") eNt.Range.FormattedText = .FormattedText .Text = vbNullString Loop End With Set eNt = Nothing Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#26
|
|||
|
|||
Thanks so much, Paul! It worked. I want to keep the same format and the {} so that I can use EndNote app to turn them into actual notes. What on the code need to be changed?
|
#27
|
||||
|
||||
You could delete:
Code:
.Characters.First.Text = vbNullString .Characters.Last.Text = vbNullString
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#28
|
|||
|
|||
It's perfect. Thank you so much, Paul! I really appreciate it.
|
Tags |
convert text to endnote, macro |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Creating macro to convert/print to pdf | shabbaranks | Word | 3 | 05-18-2011 08:59 AM |
Cross-reference endnote text | smed | Word | 3 | 01-14-2011 03:34 PM |
convert html to text at opening | etfjr | Word | 0 | 12-13-2010 11:14 AM |
Convert Number to Text | devcon | Word | 0 | 07-10-2010 01:16 AM |
Convert Dollar amount to text | GeorgeLawshe | Word | 0 | 03-07-2010 10:17 PM |