Smart questions
Smart answers
Smart people
Join Tek-Tips Forums
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Macro to add text at start and end of each lineHelpful Member!(2) 

sinbad99 (TechnicalUser) (OP)
16 Feb 12 7:46
Be grateful for guidance for a macro for adding some text at the beginning and end of many lines of text in Word.  
sinbad99 (TechnicalUser) (OP)
16 Feb 12 7:59
This is the macro I have been using, but it does seem a bit clunky. And is it possible to add some text at the end of the line at the same time?

Sub AddHello()
Dim oRg As Range
Set oRg = Selection.Range
With oRg.Find
.MatchWildcards = True
.ClearFormatting
.Replacement.ClearFormatting
.Text = "([!^13]{1,}^13)"
'.Replacement.Text = "hello\1"
.Replacement.Text = "<a href=""ancient_classics/\1"
.Wrap = wdFindStop
.Execute Replace:=wdReplaceAll
End With
Set oRg = Nothing
End Sub
fumei (TechnicalUser)
17 Feb 12 15:18
Well if you select the text...

CODE

Sub Start_End()
Selection.Text = "Add to start " & Selection.Text & _
" Add to end"
End Sub

So if you selected "yadda yadda yadda" - and it can be ANY length - you end up with:

Add to start yadda yadda yadda Add to end

Helpful Member!  fumei (TechnicalUser)
17 Feb 12 15:23
Just as a note, the string at the start (or end) does NOT have to be actual text you have in the macro.  It can be ANYTHING that is a string value.  It could text from another location in the document, text from another open document, text from a cell in a table, text from a bookmark, text from a document variable, text from an inputbox getting user input...and so on.

sinbad99 (TechnicalUser) (OP)
17 Feb 12 15:59
Thanks very much, Fumei. So I take it that whatever text is selected/highlighted will be wrapped in whatever I enter into those fields.

I've tried it and it certainly does that. Many thanks. And the coding is so simple!

However, sadly, I want to perform this on dozens of separate lines - as in a list of web addresses that I want to wrap in html code.

Is there a way to adjust the macro so that it does that, please? I suppose it won't be 'Selection.Text' but some sort of 'EachLine.Text' fashion?
Cheers paul  
macropod (TechnicalUser)
18 Feb 12 5:59
If you want to add tags both before & after the strings, you could use something like:

CODE

Sub AddTags()
With Selection.Find
  .MatchWildcards = True
  .ClearFormatting
  .Replacement.ClearFormatting
  .Text = "([!^13]{1,})"
  .Replacement.Text = "<a href=""ancient_classics/\1</a>"
  .Wrap = wdFindStop
  .Execute Replace:=wdReplaceAll
End With
End Sub
The above adds your <a href=""ancient_classics/' prefix and a '</a>' suffix to every line.

Cheers
Paul Edstein
[MS MVP - Word]

sinbad99 (TechnicalUser) (OP)
18 Feb 12 6:32
Excellent, Paul, and thanks very much for that. I notice that the cursor has to be at the start of the list, or the macro seems to use just the last line. I'm looking through each line of the macro, but I don't see where it says that. (It's probably mentioned in WordTips' big compilation of macro advice at my elbow here.)

I need this for my free ebook website, eBookTrove.com, as I have huge lists of books to be coded. I use Dreamweaver CS5, but strangely enough neither Adobe nor Macromedia before them thought to make it possible to drag large numbers of links onto the workspace in one go.

It seems then that the best way is to copy the list into Word, and use a macro to add the coding around the links. This 'ancient_classics' category that I'm coding and uploading at the moment has more than 700 titles. That's more than 700 separate actions to get the links onto the workspace.

As I've bought thousands of ebooks for the site, that process seems to take forever.

Thanks enormously for this shortcut of yours, Paul. I'll salute your help (mentioning tek-tips), and fumei's,  on the ancient-classics category page - probably tomorrow.  
Cheers paul   
macropod (TechnicalUser)
18 Feb 12 6:47
When 'Selection' is combined with '.Wrap = wdFindStop' the selection designates the starting point (and end point if even one character is selected). If you want to process the whole body of the document, irrespective of what's selected, change 'Selection' to 'ActiveDocument.Range'.

Cheers
Paul Edstein
[MS MVP - Word]

sinbad99 (TechnicalUser) (OP)
18 Feb 12 6:53
Just like magic. Thanks, Paul. I've put a thanks to you on eBookTrove's ancient_classics page, and a link to this thread, too. Many thanks.  
sinbad99 (TechnicalUser) (OP)
18 Feb 12 9:34
Is it possible to take the macro idea a stage forward - or is this sheer wild optimism?

When I use the macropod macro on 700 links, I achieve this ... and that's a very big step ahead.
..................
<a href="ancient_classics/the_wasps_by_aristophanes.epub" title="New free eBooks on eBookTrove-dot-com, and being added to all the time."> </a><br />
<a href="ancient_classics/the_water_carriers_oscar_fay_adams.epub" title="New free eBooks on eBookTrove-dot-com, and being added to all the time."> </a><br />
<a href="ancient_classics/the_way_of_an_eagle_ethel_mdell.epub" title="New free eBooks on eBookTrove-dot-com, and being added to all the time."> </a><br />
 etc etc etc (699 times)
................

Is it possible to state, to copy the words following '_classics/' and add them to the space after '.">?
And to replace the underscores with a space?
And then what about setting the words in title case?
Then removing '.epub'?

So the ideal result from running this second macro after the first would be ...

<a href="ancient_classics/the_way_of_an_eagle_ethel_mdell.epub" title="New free eBooks on eBookTrove-dot-com, and being added to all the time.">The Way of an Eagle Ethel Mdell </a><br />

Of course that result wouldn't be perfect, but it would be an astonishing timesaver.  
macropod (TechnicalUser)
18 Feb 12 16:09
Yes, all of that is possible, though getting a true title case (ie without capitalising every word) is more of a challenge.

Before proceeding, though, how much text is originally present after '.epub' (including quotes/punctuation)? I can't tell from your post whether each line already has:
" title="New free eBooks on eBookTrove-dot-com, and being added to all the time.
If that's being added by your macro, it makes a significant difference to how I'd code things. Also, does a period (ie '.') ever occur in a title?

Cheers
Paul Edstein
[MS MVP - Word]

sinbad99 (TechnicalUser) (OP)
18 Feb 12 16:30
Very good of you to be thinking about this now. Thanks very much, Paul.

Yes, the words in the title tags are mostly there for Search Engine Optimising, and are the same. Of course, in a macro I can change them around from time to time.

So in that context, '.epub' is at the end of the address for the hyperlink. That has to end in quotation marks. Then there's a space, and then the title tag, 'title="' and its message which is contained within quotes. That is to say that it always must end in quotation marks. I always put a full point before the final quotes. Then, to round it off, the square brackets close.  

The affix 'epub' is, of course, just like Word's '.doc' Sometimes it's '.dotx', and similarly the affix in ebook formats changes, too. But I can change that in the macro to suit the list I'm working on.

The actual title of the ebook doesn't have to be in title case. But the first letter ought to be in caps, of course. Conversely, of course, it won't do much harm if the first letter of all the words in the book title are capped - I mean, 'a', 'of' etc.

And the whole thing, the site, is strictly a non-money making thing. It's a hobby that shares ebooks I have bought and so hopefuly the visitors are not going to be sticklers for absolutely correct punctuation. (And many of them are Americans, so they wouldn't recognise proper punctuation. :))

Very good of you to think about this. As well as helping enormously with the coding for the site, it is bringing back a lot of what I used to know of Word macros. So it's enjoyable for me in this other way, too.
 
macropod (TechnicalUser)
19 Feb 12 22:37
hi sinbad99,

What does the text look like before you've done any processing? For example:
"ancient_classics/the_wasps_by_aristophanes.epub"
or:
"ancient_classics/the_wasps_by_aristophanes.epub" title="New free eBooks on eBookTrove-dot-com, and being added to all the time."

With the output, does it matter if all the underscores are removed and the title is converted to proper case on both sides? For example:
<a href="ancient_classics/The Way of an Eagle Ethel Mdell.epub" title="New free eBooks on eBookTrove-dot-com, and being added to all the time.">The Way of an Eagle Ethel Mdell </a><br />

I also note that you mentioned removing '.epub', but your 'ideal' result still includes it. Please confirm what the correct output is.

Cheers
Paul Edstein
[MS MVP - Word]

sinbad99 (TechnicalUser) (OP)
20 Feb 12 10:00
Hello Paul
1. Before there's any processing, there's just the name of the file. It usually has spaces between each word, and the case is erratic.

I put the original epub file into its place - folder - on the site, in this case 'ancient_classics'. If I coded with VBA, that would be 'AncientClassics'. (Of course, it could be either, but these days I use the php/mysql way with an underscore between each word.)

So the next stage is to make it read 'ancient_classics/the_wasps_by_aristophanes.epub'

2. You ask if this would be ok - '<a href="ancient_classics/The Way of an Eagle Ethel Mdell.epub" title="New free eBooks on eBookTrove-dot-com, and being added to all the time.">The Way of an Eagle Ethel Mdell </a><br />'

This part, the code, mustn't have spaces -'<a href="ancient_classics/The Way of an Eagle Ethel Mdell.epub"

So '/The Way of an Eagle Ethel Mdell.epub' should be '/TheWayOfAnEagleEthelMdell.epub' or with underscores in the spaces.

3. Sorry, I've not been clear.Ideally, the part that appears as text on the page, that is the words that follow '.">'wouldn't have the format showing, that is the '.ePub' affix.

So here is the ideal way that an ebook would go onto the server ...  

<a href="ancient_classics/the_way_of_an_eagle_ethel_mdell.epub" title="New free eBooks on eBookTrove-dot-com, and being added to all the time.">The Way of an Eagle by Ethel Mdell </a><br />

I know I've added a 'by' because it seems to be the name of the author, but that isn't necessary, and if it were, could be added by hand.

Phew, I've troubled you with lots of words here, Paul. Very good of you to stick with it. And many apologies if I have made the process longer than necessary.

Many thanks for getting this far.
Cheers paul
 
macropod (TechnicalUser)
20 Feb 12 16:22
Hi sinbad,

1. So, are you saying that what you're starying with is nothing more than titles, like:
the way of an eagle ethel mdell
with spaces (not underscores), no '.epub' or anything else? If so, that's markedly different to what you've described before.

2. No problem.

3. As for inserting 'by', that's not a practical proposition - there's no way to determine where it should go.

Cheers
Paul Edstein
[MS MVP - Word]

sinbad99 (TechnicalUser) (OP)
20 Feb 12 16:51
Sorry, Paul, I hope I've not confused you.

To show the title, and to have a link to the ebook, I need to code where the link is - which as we know is ancient-classics/. That's the folder the ebook is in.

Then we give the name of the file. That's '/the_way_of_an_eagle_ethel_mdell.epub"

Together, that is coded as '<a href="ancient_classics/the_way_of_an_eagle_ethel_mdell.epub"

Within the angle brackets, we include a title-tag, which shows when the cursor hovers over it. But we do it in this situation mainly so that Search Engine robots will note it.

So the complete CODE side of linking to the ebook is '<a href="ancient_classics/the_way_of_an_eagle_ethel_mdell.epub" title="New free eBooks on eBookTrove-dot-com, and being added to all the time.">

Next we add the title that you actually see on the webpage, which is 'The Way of an Eagle by Ethel Mdell'

Then we finish off the code with an '</a>'

To put the following entry on a separate line, we add <br />

And the whole thing, for each ebook is '<a href="ancient_classics/TheWayOfAnEagleEthelMdell.epub" title="New free eBooks on eBookTrove-dot-com, and being added to all the time.">The Way of an Eagle Ethel Mdell </a><br />'

The link can be done the VBA way, or with underscores in place of spaces.

I hope this makes it clear to you. Sorry that it is complicated. Many thanks for getting this far with it.  
macropod (TechnicalUser)
20 Feb 12 22:26
Hi sinbad,

That's all very well, but you haven't answered my question about what the text is before you start processing. Is it like:
the way of an eagle ethel mdell
or is is like:
the way of an eagle ethel mdell.epub
or is it something else? If so, what? Give some examples.

If you don't say what the starting point is, you can't expect anyone to code the macro correctly.

Cheers
Paul Edstein
[MS MVP - Word]

macropod (TechnicalUser)
21 Feb 12 2:00
Hi sinbad,

Try the following macro. Since a macro can't can't tell where 'by' should go, the macro highlights any strings that don't already have 'by' in them. You will need to add it to those strings. You will also need to check the other results, as 'by' may be in the title and not before the author's name.

CODE

Sub ByTest()
Application.ScreenUpdating = False
Dim StrBkTrv As String, StrStrt As String, StrEnd As String, StrTmp As String, StrTtl As String
StrBkTrv = ".epub"" title=""New free eBooks on eBookTrove-dot-com, and being added to all the time."">"
StrStrt = "<a href=""ancient_classics/"
StrEnd = "</a><br />"
With ActiveDocument.Range
  With .Find
    .MatchWildcards = True
    .ClearFormatting
    .Replacement.ClearFormatting
    .Wrap = wdFindStop
    .Execute Replace:=wdReplaceAll
    .Text = "[!^13]{1,}"
    .Replacement.Text = ""
    .Execute
  End With
  Do While .Find.Found
    StrTmp = Split(.Text, ".epub")(0)
    StrTmp = Trim(Replace(StrTmp, "_", " "))
    If InStr(StrTmp, "by ") = 0 Then .HighlightColorIndex = wdYellow
    .Collapse wdCollapseEnd
    .Find.Execute
  Loop
End With
Application.ScreenUpdating = True
End Sub
Once you'd fixed up all the 'by' entries, run the following macro. Since I don't really know what you're starting point is, I've coded for a number of possibilities.

Most of the work is done by the ProperCase function. It took a lot of work to develop this!! If the list of exclusions from the upper-case conversion is too broad, you can delete the ones you don't want. Alternatively you can add more. 'Surnames like O', Mc & Mac and hyphenated names are converted to proper case. If there are other kinds you need to treat in the same way, you'll need to go through the output - or add to the function's routines. You'll still need to check the output, though, as there may be some scenarios I've missed.

CODE

Sub AddTags()
Application.ScreenUpdating = False
Dim StrBkTrv As String, StrStrt As String, StrEnd As String, StrTmp As String, StrTtl As String
StrBkTrv = ".epub"" title=""New free eBooks on eBookTrove-dot-com, and being added to all the time."">"
StrStrt = "<a href=""ancient_classics/"
StrEnd = "</a><br />"
With ActiveDocument.Range
  With .Find
    .MatchWildcards = True
    .ClearFormatting
    .Replacement.ClearFormatting
    .Wrap = wdFindStop
    .Execute Replace:=wdReplaceAll
    .Text = "[!^13]{1,}"
    .Replacement.Text = ""
    .Execute
  End With
  Do While .Find.Found
    StrTmp = Split(.Text, ".epub")(0)
    StrTmp = Trim(Replace(StrTmp, "_", " "))
    While Right(StrTmp, 1) = "."
      StrTmp = Left(StrTmp, Len(StrTmp) - 1)
    Wend
    While InStr(StrTmp, "  ") > 0
      StrTmp = Replace(StrTmp, "  ", " ")
    Wend
    StrTmp = Replace(StrTmp, " ", "_")
    StrTtl = ProperCase(StrTxt:=Replace(StrTmp, "_", " "), bCaps:=False, bExcl:=False)
    .Text = StrStrt & StrTmp & StrBkTrv & StrTtl & StrEnd
    If InStr(StrTtl, "by ") = 0 Then .HighlightColorIndex = wdYellow
    .Collapse wdCollapseEnd
    .Find.Execute
  Loop
End With
Application.ScreenUpdating = True
End Sub

Function ProperCase(StrTxt As String, Optional bCaps As Boolean, Optional bExcl As Boolean) As String
'Convert an input string to proper-case.
'Surnames like O', Mc & Mac and hyphenated names are converted to proper case also.
'If bCaps = False, then upper-case strings like ABC are preserved; otherwise they're converted.
'If bExcl = False, words in the exclusion list are retained as lower-case, unless after specified punctuation marks.
Dim i As Long, j As Long, k As Long, l As Long, bFnd As Boolean
Dim StrChr As String, StrExcl As String, StrMac As String, StrPunct As String, StrTmpA As String, StrTmpB As String
'exclusion list
StrExcl = " a , an , and , as , at , but , by , for , from , if , in , is , of , on , or , the , this , to , with "
' Mac name lower-case list
StrMac = "Macad,Macau,Macaq,Macaro,Macass,Macaw,Maccabee,Macedon,Macerate,Mach,Mack,Macle,Macrame,Macro,Macul,Macumb"
StrPunct = "!,:,.,?,"""
If bExcl = True Then
  StrExcl = ""
  StrPunct = ""
End If
If Len(Trim(StrTxt)) = 0 Then
  ProperCase = StrTxt
  Exit Function
End If
If bCaps = True Then StrTxt = LCase(StrTxt)
StrTxt = " " & StrTxt & " "
For i = 1 To UBound(Split(StrTxt, " "))
  StrTmpA = " " & Split(StrTxt, " ")(i) & " "
  StrTmpB = UCase(Left(StrTmpA, 2)) & Right(StrTmpA, Len(StrTmpA) - 2)
  StrTxt = Replace(StrTxt, StrTmpA, StrTmpB)
Next i
StrTxt = Trim(StrTxt)
'Code for handling O' names
For i = 1 To UBound(Split(StrTxt, "'"))
  If InStr(Right(Split(StrTxt, "'")(i - 1), 2), " ") = 1 Or _
    Right(Split(StrTxt, "'")(i - 1), 2) = Right(Split(StrTxt, "'")(i - 1), 1) Then
    StrTmpA = Split(StrTxt, "'")(i)
    StrTmpB = UCase(Left(StrTmpA, 1)) & Right(StrTmpA, Len(StrTmpA) - 1)
    StrTxt = Replace(StrTxt, StrTmpA, StrTmpB)
  End If
Next
'Code for handling hyphenated names
For i = 1 To UBound(Split(StrTxt, "-"))
  StrTmpA = Split(StrTxt, "-")(i)
  StrTmpB = UCase(Left(StrTmpA, 1)) & Right(StrTmpA, Len(StrTmpA) - 1)
  StrTxt = Replace(StrTxt, StrTmpA, StrTmpB)
Next
'Code for handling names starting with Mc
If Left(StrTxt, 2) = "Mc" Then
  Mid(StrTxt, 3, 1) = UCase(Mid(StrTxt, 3, 1))
End If
i = InStr(StrTxt, " Mc")
If i > 0 Then
  Mid(StrTxt, i + 3, 1) = UCase(Mid(StrTxt, i + 3, 1))
End If
'Code for handling family names starting with Mac
If Left(StrTxt, 3) = "Mac" Then
  bFnd = False
  For j = 0 To UBound(Split(StrMac, ","))
    If InStr(Split(StrTxt, " ")(0), Split(StrMac, ",")(j)) > 0 Then
      bFnd = True
      Exit For
    End If
  Next
  If bFnd = False Then
    If Len(Split(Trim(StrTxt), " ")(0)) > 4 Then
      Mid(StrTxt, 4, 1) = UCase(Mid(StrTxt, 4, 1))
    End If
  End If
End If
i = InStr(StrTxt, " Mac")
If i > 0 Then
  If Len(StrTxt) > i + 4 Then
    bFnd = False
    For j = 0 To UBound(Split(StrMac, ","))
      If InStr(Split(Mid(StrTxt, i + 1, Len(StrTxt) - i - 1), " ")(0), Split(StrMac, ",")(j)) > 0 Then
        bFnd = True
        Exit For
      End If
    Next
    If bFnd = False Then
      Mid(StrTxt, i + 4, 1) = UCase(Mid(StrTxt, i + 4, 1))
    End If
  End If
End If
'Code to restore excluded words to lower case
For i = 0 To UBound(Split(StrExcl, ","))
  StrTmpA = Split(StrExcl, ",")(i)
  StrTmpB = UCase(Left(StrTmpA, 2)) & Right(StrTmpA, Len(StrTmpA) - 2)
  If InStr(StrTxt, StrTmpB) > 0 Then
    StrTxt = Replace(StrTxt, StrTmpB, StrTmpA)
    'Make sure an excluded words following punctution marks are given proper case anyway
    For j = 0 To UBound(Split(StrPunct, ","))
      StrChr = Split(StrPunct, ",")(j)
      StrTxt = Replace(StrTxt, StrChr & StrTmpA, StrChr & StrTmpB)
    Next
  End If
Next
ProperCase = StrTxt
End Function

Cheers
Paul Edstein
[MS MVP - Word]

macropod (TechnicalUser)
21 Feb 12 2:13
Corrections to the first macro -
change:

CODE

Application.ScreenUpdating = False
Dim StrBkTrv As String, StrStrt As String, StrEnd As String, StrTmp As String, StrTtl As String
StrBkTrv = ".epub"" title=""New free eBooks on eBookTrove-dot-com, and being added to all the time."">"
StrStrt = "<a href=""ancient_classics/"
StrEnd = "</a><br />"
With ActiveDocument.Range
to:

CODE

Application.ScreenUpdating = False
Dim StrTmp As String
With ActiveDocument.Range
and change:

CODE

If InStr(StrTmp, "by ") = 0 Then .HighlightColorIndex = wdYellow
to:

CODE

If InStr(StrTmp, " by ") = 0 Then .HighlightColorIndex = wdYellow

Cheers
Paul Edstein
[MS MVP - Word]

sinbad99 (TechnicalUser) (OP)
21 Feb 12 4:11
Macropod for President! This looks amazing, Paul, and a lot of hard mental work. I should be able to try this out in an hour or so. I'll report back straight away. Phew, this is grown-up coding. No wonder Mr Gates sees you as a Most Valuable Professional. Thank you. Back soon.  
sinbad99 (TechnicalUser) (OP)
21 Feb 12 7:03
Hello Paul - Copying, changing as per your corrections, the first macro.

It is interrupted by 'Compile error: Sub or Function not defined' on this line -
 StrTtl = ProperCase(StrTxt:=Replace(StrTmp, "_", " "), bCaps:=False, bExcl:=False)

and 'ProperCase" is highlighted.

Sorry to need to come back with things like this. You've done a real marathon job here.  
sinbad99 (TechnicalUser) (OP)
21 Feb 12 9:20
I meant the second macro, Macropod. The first sets the text into a brilliant canary yellow. I've been seaching online for anything that suggests how to define ProperCase, but without success.  
MakeItSo (Programmer)
21 Feb 12 9:23
Have you copied ALL of macropods code, including this block:

CODE

Function ProperCase(StrTxt As String, Optional bCaps As Boolean, Optional bExcl As Boolean) As String
...
...
...
End Function
?
Cheers,
MakeItSo

"Knowledge is power. Information is liberating. Education is the premise of progress, in every society, in every family." (Kofi Annan)
Oppose SOPA, PIPA, ACTA; measures to curb freedom of information under whatever name whatsoever.

sinbad99 (TechnicalUser) (OP)
21 Feb 12 9:35
Thanks, MakeItSo. I was taking them one at a time, forgetting - I think - that the code is read from bottom up. Yes, that problem's gone. Many thanks.  
macropod (TechnicalUser)
21 Feb 12 15:47
Hi sinbad,

Quote:

I was taking them one at a time, forgetting - I think - that the code is read from bottom up.
No, that's no how it works. What happens is that the AddTags sub passes a string to the ProperCase function, which then returns a parsed version of that string to the AddTags sub for incorporation into the output.

Cheers
Paul Edstein
[MS MVP - Word]

sinbad99 (TechnicalUser) (OP)
21 Feb 12 16:00
Yes, so I learned, Macropod. Back from a meeting, and now about to see how it works.  
sinbad99 (TechnicalUser) (OP)
21 Feb 12 16:03
To be certain of your last bit of advice, Macropod: I do run one macro after the other, don't I? Get the one that highlights in yellow to run first, and then the next?
sinbad99 (TechnicalUser) (OP)
21 Feb 12 16:45
I suspect the problem comes with the lines in Sub AddTags() that I had to replace. You quote 6 lines to be replaced by 3,lines.

But I suspect, Macropod, you don't mean all 6 lines to be replaced.  
Helpful Member!  macropod (TechnicalUser)
21 Feb 12 17:40
Hi sinbad,

You don't have to run the first macro at all, if you don't want to. It's only there to help you to find book/author listings that lack the by key word. So, if you have:
the way of an eagle ethel mdell
that will be highlighted, but:
the way of an eagle by ethel mdell
won't be highlighted. Be careful, though, because:
the way by an eagle ethel mdell
won't be highlighted either.

Quote:

I suspect the problem comes with the lines in Sub AddTags() that I had to replace. You quote 6 lines to be replaced by 3,lines.
Why are you changing the AddTags macro? I haven't suggested that. The only changes I suggested were to the ByTest macro. For the ByTest macro, you do replace 6 lines with 3 lines - and 1 line with 1 line.

Cheers
Paul Edstein
[MS MVP - Word]

sinbad99 (TechnicalUser) (OP)
22 Feb 12 5:37
That's really terrific, Macropod. Confusion over which macro was to take the changes delayed things, but now I see it is working, well, like a miracle. Such labour-intensive production is turned into something really quick.

And changes are simple. For example, a number of children's books are in pdf format. I can change the 'epub' to 'pdf' in the macro or quicker still, run a Find and Replace function either in Word or in Dreamweaver.

Really grateful, Paul. It's also got me thinking about macros again, which I used to enjoy. (I think you might be from enzed. I lived there for many years. Now I'll remember a great MS MVP from that part of the world.) Thanks enormously, Macropod.  
macropod (TechnicalUser)
22 Feb 12 5:56

Quote:

I think you might be from enzed.
OZ, actually.

Cheers
Paul Edstein
[MS MVP - Word]

sinbad99 (TechnicalUser) (OP)
22 Feb 12 5:59
Apologies. Been there, many times. Great place. Very grateful for your hard work, Macropod.  

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close