#1
|
|||
|
|||
Help with debugging fairly simple "selection.cut" error.
Help with debugging fairly simple (I hope) "selection.cut" error.
Ok, I 'wrote' these macros back in 2010... basically the system basically recorded my actions and saved into code. These have worked ever since and I've forgotten a lot... and I knew almost nothing to begin with! Anyways, one section is now erroring out. I've changed nothing, same Word I've been using for some time now, same code I've been using for well over a decade. I don't even remember what EXACTLY SPECIFICALLY these do anymore, just that they work for what I need. I've edited my post to hopefully just show the relevant section versus the entire code. Here's the sub-section I've having issues with. It's erroring out at 'selection.cut'. -------------------------------------------------- Selection.Find.Execute Selection.HomeKey Unit:=wdLine Selection.MoveUp Unit:=wdScreen, Count:=3, Extend:=wdExtend Selection.Cut Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = "^p^p^p" .Replacement.Text = "^p^p" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With -------------------------------------------------- Basically, this is just part of several macros I use to edit/fix e-Books so they display/view better. It's been a minute, but I think I'm copying everything ABOVE where any "Chapter One" begins, running all the steps, then pasting back in when completed. This worked for years, and now just stopped working. Sorry if I've made this more difficult than it should be. Calling me a novice at this would be a massive upgrade, I really know nothing. If you do know the fix, please treat me like a total moron and explain so I'd understand what to change. Greg Last edited by GDA63378; 08-03-2023 at 08:37 PM. |
#2
|
||||
|
||||
The order of the lines actually matters.
The Selection.Find.Execute should be the last line, not the first. If you cut the selection, the cursor will be showing no selection so that Selection.Find will be working across the whole document. Your code doesn't then paste the cut section back in to the document but even if you added that back in, it likely would go to the location where the last replace happened. If Selection.Cut is throwing an error, perhaps you have selected something that is protected and can't be removed.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#3
|
|||
|
|||
I've been using this exact same code for the past 13 years. No recent updates to Word, I certainly did not change the code. Maybe the rest of that macro would help, but it'd pretty long, so I thought perhaps posting the more relevant section would suffice. I don't know.
|
#4
|
|||
|
|||
I've given up resolving the error. I'm now looking for someone to hire to write all brand macros/code. It's mostly all pretty simple find/replace stuff, maybe a couple items a little more difficult than that, but I figure an expert should have everything I want done in a couple hours. We can negotiate pay after you see the list of macros I desire. Feel free to private message if interested in discussing.
|
#5
|
|||
|
|||
FYI: I've found someone I'm working with to assist in rewriting all brand-new code. If something changes and I need to hire someone else, I'll update.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Excel 2003: VBA "Function" causes "#VALUE!" errors after running "insert/delete row" custom macro | Matt C | Excel Programming | 2 | 01-08-2022 06:03 AM |
"Word found unreadable content..." + "Word experienced an error trying to open..." | onas | Word | 1 | 09-02-2019 10:52 AM |
typing "scr" and problem with "extending selection" | danielmatt | Word | 16 | 07-21-2019 12:31 PM |
Error: "Changes made were lost...reconnect with server", when switching "from" field | randhurrle | Outlook | 2 | 02-25-2015 06:51 PM |
Selection.Bookmarks("\headinglevel") WITHOUT Selection | NobodysPerfect | Word VBA | 3 | 01-14-2015 12:58 PM |