Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-29-2011, 06:34 PM
Orifacious Orifacious is offline Macro to convert text to endnote? Windows XP Macro to convert text to endnote? Office 2000
Novice
Macro to convert text to endnote?
 
Join Date: May 2011
Posts: 4
Orifacious is on a distinguished road
Default Macro to convert text to endnote?

Hi, gang.
I have a good number of Word files (Word 2000) containing entries with source citations enclosed between brackets, like this:
<Brady, S.F.Independent, 3-24-92>
Over time, however, I've accumulated enough such citations, that it sort of hampers the ability to visually read the text, so I'd like to convert those "in-line" citations into endnotes.

I've been trying (unsuccessfully) for a while now to figure out how to write a macro that would do the following:



* Search for all instances of text contained between a "<" and a ">".
* Allow for a "Replace" or "Find Next" option (as in Search/Replace) so that I could choose to skip a particular instance if desired and move on the next find.
* If choose NOT to skip ("Find Next"), then strip out the "<" and ">", and then convert the remaining text (what was originally between the "< >") into an endnote.

This would clean up the text itself, while preserving the specific citations and their connection to the particular text in the doc, nicely tucked into the endnote section.

Any ideas?
Reply With Quote
  #2  
Old 05-29-2011, 11:13 PM
macropod's Avatar
macropod macropod is offline Macro to convert text to endnote? Windows 7 32bit Macro to convert text to endnote? Office 2007
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Cross-posted at: http://social.technet.microsoft.com/...f-27ff46b3f340

Orifacious: For cross-posting etiquette, please read: http://www.excelguru.ca/node/7
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 05-30-2011, 06:22 PM
Orifacious Orifacious is offline Macro to convert text to endnote? Windows XP Macro to convert text to endnote? Office 2000
Novice
Macro to convert text to endnote?
 
Join Date: May 2011
Posts: 4
Orifacious is on a distinguished road
Default Sorry for the cross-post

Didn't understand that ethic sitch; do now.
Reply With Quote
  #4  
Old 06-01-2011, 03:39 AM
macropod's Avatar
macropod macropod is offline Macro to convert text to endnote? Windows 7 32bit Macro to convert text to endnote? Office 2007
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi Orifacious,

Try:
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 = "\<[!\>\<]{1,}\>"
    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
Note: the code searches the selected range (or from the insertion point if nothing is selected)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]

Last edited by macropod; 06-02-2011 at 06:49 PM.
Reply With Quote
  #5  
Old 06-01-2011, 05:57 PM
Orifacious Orifacious is offline Macro to convert text to endnote? Windows XP Macro to convert text to endnote? Office 2000
Novice
Macro to convert text to endnote?
 
Join Date: May 2011
Posts: 4
Orifacious is on a distinguished road
Default

Wow! That works fast and neat. Thanks!
Is there any way to make it hi-light the placemarker for the endnote in the main text? I find those little guys hard to see in a big text file, and usually hi-light them yellow.

One minor problem is that the macro doesn't pause at each found instance (and give the option to perform the conversion or else move to the next found instance), but just zips right through the whole file like a bullet.

I have occasionally used those same brackets ( "< >" ) to indicate other things as well --I know, sloppy, and a bad symbol to use anyway, since it's prone to be interpreted in macros as a find function switch rather than an actual character-- so it would be nice if I could pause at each find and decide on a per case basis to perform the endnote conversion or not.

But believe me, it's much less work pulling the errant misconversions back out of the endnotes than hunting and converting each one, so really thanks! Don't think I could ever have figged that one out.
Reply With Quote
  #6  
Old 06-01-2011, 07:48 PM
macropod's Avatar
macropod macropod is offline Macro to convert text to endnote? Windows 7 32bit Macro to convert text to endnote? Office 2007
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by Orifacious View Post
Is there any way to make it hi-light the placemarker for the endnote in the main text? I find those little guys hard to see in a big text file, and usually hi-light them yellow.
For that you could modify the 'Endnote Reference' Style to have, say, a bold font and yellow shading.
Quote:
Originally Posted by Orifacious View Post
One minor problem is that the macro doesn't pause at each found instance (and give the option to perform the conversion or else move to the next found instance), but just zips right through the whole file like a bullet.

I have occasionally used those same brackets ( "< >" ) to indicate other things as well --I know, sloppy, and a bad symbol to use anyway, since it's prone to be interpreted in macros as a find function switch rather than an actual character-- so it would be nice if I could pause at each find and decide on a per case basis to perform the endnote conversion or not.
Yes, how sloppy of you

Rather than complicating the macro further, you could use a wildcard Find/Replace with:
Find = (\<)([!\>\<]{1,})(\>)
Replace = {\2}
to change the '<*>' strings you don't want converted to endnotes to '{*}' strings (use something other than '{' and '}' if those characters are already in use), stepping through the Find/Replace process. Then run the macro. If you want to get the '<*>' strings back again afterwards, simply reverse the Find/replace process:
Find = (\{)([!\}\{]{1,})(\})
Replace = <\2>
and this time you won't need to step through.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 06-02-2011, 12:11 PM
Orifacious Orifacious is offline Macro to convert text to endnote? Windows XP Macro to convert text to endnote? Office 2000
Novice
Macro to convert text to endnote?
 
Join Date: May 2011
Posts: 4
Orifacious is on a distinguished road
Default

Excellent advice, and I thank you!

Actually, I felt retroactively dumb for having come back with the bit about how to hi-light an endnote reference, since I do know how to format a style or two; but had my head wrapped up in the macro at the mome. I figured that one out as soon as I'd backed off of posting the message.

But the search & replace is helpful, and rounds out my need, as it were, so thanks again!
Reply With Quote
  #8  
Old 08-09-2011, 01:53 AM
GJohansson GJohansson is offline Macro to convert text to endnote? Windows 7 32bit Macro to convert text to endnote? Office 2007
Novice
 
Join Date: Aug 2011
Posts: 17
GJohansson is on a distinguished road
Default the macro gives error 5560 whats the problem?

I run the macro in word and i mark a word inside brackets <test>. But take error 5560 run time error visual basic. And says the text in find contains a wrong expression.
Attached Images
File Type: jpg Untitled.jpg (42.2 KB, 38 views)
Reply With Quote
  #9  
Old 08-09-2011, 03:38 AM
macropod's Avatar
macropod macropod is offline Macro to convert text to endnote? Windows 7 64bit Macro to convert text to endnote? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

That suggests you may be working with a Windows regional setting that doesn't accept some of the english-language expressions. Try changing:
.Text = "\<[!\>\<]{1,}\>"
to:
.Text = "\<[!\>\<]{1;}\>"
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #10  
Old 08-09-2011, 03:57 AM
GJohansson GJohansson is offline Macro to convert text to endnote? Windows 7 32bit Macro to convert text to endnote? Office 2007
Novice
 
Join Date: Aug 2011
Posts: 17
GJohansson is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
That suggests you may be working with a Windows regional setting that doesn't accept some of the english-language expressions. Try changing:
.Text = "\<[!\>\<]{1,}\>"
to:
.Text = "\<[!\>\<]{1;}\>"
Thats working makropod, thanks a lot...
But let me ask you something and if you know tell me because im new on the computing.
1.I wonder if i can replace the <> with other characters such us {} or [] is this difficult to chance something like that?
2.Is difficult to change the <> inside brackets text, not to endnote but to plain text without brackets, or the option to delete this text with the brackets together?

Anyway, thanks a lot for your apply.
Reply With Quote
  #11  
Old 08-09-2011, 04:10 AM
macropod's Avatar
macropod macropod is offline Macro to convert text to endnote? Windows 7 64bit Macro to convert text to endnote? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi Saints,

You can certainly change the '<' and '>' characters to something else - they're only in the code to meet the OP's requirements. Simply deleting them would be problematic, because the code is written to look for the longest possible string not containing those characters.
I'm not sure what you mean with your second question. If all you want to do is to delete the '<' and '>' characters (and, perhaps, remove character formatting from the intervening text), you wouldn't need this kind of macro - a wildcard Find/Replace would do the job, where:
Find = \<([!\>\<]{1;})\>
Replace = \1
and you set the Replacement font style to 'regular' with no 'effects'.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #12  
Old 08-09-2011, 04:17 AM
GJohansson GJohansson is offline Macro to convert text to endnote? Windows 7 32bit Macro to convert text to endnote? Office 2007
Novice
 
Join Date: Aug 2011
Posts: 17
GJohansson is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Hi Saints,

You can certainly change the '<' and '>' characters to something else - they're only in the code to meet the OP's requirements. Simply deleting them would be problematic, because the code is written to look for the longest possible string not containing those characters.
I'm not sure what you mean with your second question. If all you want to do is to delete the '<' and '>' characters (and, perhaps, remove character formatting from the intervening text), you wouldn't need this kind of macro - a wildcard Find/Replace would do the job, where:
Find = \<([!\>\<]{1;})\>
Replace = \1
and you set the Replacement font style to 'regular' with no 'effects'.
Thanks a lot makropod, simply the best...... And the quickiest.... Whenever you want something just pm me.
Reply With Quote
  #13  
Old 08-09-2011, 02:03 PM
GJohansson GJohansson is offline Macro to convert text to endnote? Windows 7 32bit Macro to convert text to endnote? Office 2007
Novice
 
Join Date: Aug 2011
Posts: 17
GJohansson is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Hi Saints,

You can certainly change the '<' and '>' characters to something else - they're only in the code to meet the OP's requirements. Simply deleting them would be problematic, because the code is written to look for the longest possible string not containing those characters.
I'm not sure what you mean with your second question. If all you want to do is to delete the '<' and '>' characters (and, perhaps, remove character formatting from the intervening text), you wouldn't need this kind of macro - a wildcard Find/Replace would do the job, where:
Find = \<([!\>\<]{1;})\>
Replace = \1
and you set the Replacement font style to 'regular' with no 'effects'.
Macropod i would like know if there is something like that to do with the footnotes insteed of endnotes?
Reply With Quote
  #14  
Old 08-11-2011, 05:50 AM
macropod's Avatar
macropod macropod is offline Macro to convert text to endnote? Windows 7 64bit Macro to convert text to endnote? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

That's a fairly trivial change:

1. Change the macro's name;
2. Change -
ActiveDocument.Endnotes.Add RngFnd, , StrNote
to -
ActiveDocument.Footnotes.Add RngFnd, , StrNote
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #15  
Old 08-11-2011, 07:45 AM
GJohansson GJohansson is offline Macro to convert text to endnote? Windows 7 32bit Macro to convert text to endnote? Office 2007
Novice
 
Join Date: Aug 2011
Posts: 17
GJohansson is on a distinguished road
Default Thanks a lot

Quote:
Originally Posted by macropod View Post
That's a fairly trivial change:

1. Change the macro's name;
2. Change -
ActiveDocument.Endnotes.Add RngFnd, , StrNote
to -
ActiveDocument.Footnotes.Add RngFnd, , StrNote
Thats working excellent thanks a lot.
Reply With Quote
Reply

Tags
convert text to endnote, macro

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to convert text to endnote? Creating macro to convert/print to pdf shabbaranks Word 3 05-18-2011 08:59 AM
Macro to convert text to endnote? 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

Other Forums: Access Forums

All times are GMT -7. The time now is 10:53 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft