Hi Hans, Hi Jay Freedman,
Thanks for the extra input :)
My final version I ended up using_....
Code: Select all
Sub Makro9() '
Selection.InsertBefore "[color=Blue]"
Selection.InsertAfter "[/color]"
End Sub
_..... was not too far off, but I think I can follow your codes.
For doing stuff on a single word or short sentences then this_..
Code: Select all
Selection.Text = "[color=Blue]" & Selection.Text & "[/color]"
_.. looks the thing to go for
The little bit of computer knowledge that I have is in Excel VBA. My work there is often to do with manipulating big files and I have got into the habit of often putting things into Arrays and working “internally” before then pasting back Big Arrays out in one or a few steps
The analogy here with my VBA work would be if I was looking manually and changing a Cell or two, in which case a similar code would work there also.
I probably have a bit of a conceptual problem of what a Selection is in WORD VBA. ( or a Range come to think of it ). In VBA Selection is a Range Object.
For the little I use Word VBA I probably don’t need to worry too much – I have enough problems trying to understand some Excel VBA Logic,.. Lol... Although stretching the mind is never a bad thing. :)
_......
@ Jay Freedman
Thanks for the other info.
When I post in Forums it is sometimes a learning thing , mostly here at Eileen’s Lounge I ask questions, but on other forums, I mostly answer, ( But in doing so also learn a lot ) … and I have a bit of a ( bad ! ) reputation of including lots of extra steps,
‘Comments etc.. A select minority of people love it, most hate it. :(
Codes that I use just for myself are often a lot different. If I have time I do 2 code versions,
_ - a full code that has extra lines variable and a book load of
‘Comments
_ - a much more condensed version – I have a few awesome “one liner codes” – that is one thing that I find an interesting aspect of Object Orientated Programming which still occasionally seems a wiered concept to my Old Fortran, Pascal, Basic brain
_..
I understand what you are saying about the
Let,
Set stuff.. but I often forget the differences, and so I always include( in my full code versions ) the
Let to remind me of things I can
Let , things I should
Set , and things I should not do either. And also until recently my last Computer experience was about 25 – 30 years ago, so I got used to
Let in Basic,
_- Along with
Rem and code lines it has become another Trademark of mine to love or hate.
The
…”… … in a simple macro like this, you can omit the Set rng = Nothing statement and just let VBA destroy the object when it goes out of scope (when the macro ends). ….”… is a good point to know about in WORD VBA, so thanks for that.
This thinking is something that I do “subscribe to” mostly, at least in VBA. – A lot of the ( younger ) experts have said something similar to me in VBA.
As it is not needed it is better not to use it so as not to mask the cases ( exceptions apparently in VBA do exists ) when that should be done. Ironically I got that habit from much more Senior Experts who claimed or thought it was necessary. Apparently, some strange sort of leakage, Thrashing , Uncleared memory or the such problems used to occur once with these things.
But I actually have some headaches in a similar area currently, and one of the few things I can say is that doing a
Set =
Nothing has never made any difference. So I am with you on that one
Alan
I am having difficulty logging in with this account just now.
You can find me at DocAElstein also