Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro to add text at start and end of each line 2

Status
Not open for further replies.

sinbad99

Technical User
Feb 16, 2012
34
GB
Be grateful for guidance for a macro for adding some text at the beginning and end of many lines of text in Word.
 
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.
 
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.
 
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.
 
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.
 
Hi sinbad,
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]
 
Yes, so I learned, Macropod. Back from a meeting, and now about to see how it works.
 
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?
 
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.
 
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.
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]
 
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.
 
Apologies. Been there, many times. Great place. Very grateful for your hard work, Macropod.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top