Hey all, I'm a newbie at Word VBA so I appreciate any insights you can provide.
My desire:
Augment each number in the string by 1 (or user choice)
Lorem ipsum dolor 50 sit amet, consectetur 1982 adipiscing elit, sed do 23 eiusmod tempor incididunt ut labore et 2018 dolore magna aliqua.
My code:
In problem line, it says object required.Please Login or Register to view this content.
The code works if I strip away the RTrim, CDbl and Cstr functions, but then it removes the trailing space and squishes the words together. If I manually add a space such as item.text + inc & " " then it doesn't move to next word. Word crashes unless I'm stepping line by line, in which case same word keeps incrementing, does not move forward. Not sure why. In the watch window, the Words collection does not increase in size.
So, looking up the documentation, we're suppose to remove trailing spaces with RTrim and that works. When I do that, it says object required. So I thought, aha, type mismatch. Convert text to double (even though it worked before) and then back to string but no matter what combination I use, I keep getting "object required". The "item" object is still a range, that doesn't change I believe. I have plugged everything into the watch window and it still looks valid.
Help?
Bookmarks