Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-03-2023, 03:24 PM
GDA63378 GDA63378 is offline Help with debugging fairly simple "selection.cut" error. Windows 10 Help with debugging fairly simple "selection.cut" error. Office 2019
Novice
Help with debugging fairly simple "selection.cut" error.
 
Join Date: Aug 2023
Posts: 5
GDA63378 is on a distinguished road
Default 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.
Reply With Quote
  #2  
Old 08-06-2023, 03:37 PM
Guessed's Avatar
Guessed Guessed is offline Help with debugging fairly simple "selection.cut" error. Windows 10 Help with debugging fairly simple "selection.cut" error. Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
Reply With Quote
  #3  
Old 08-06-2023, 03:52 PM
GDA63378 GDA63378 is offline Help with debugging fairly simple "selection.cut" error. Windows 10 Help with debugging fairly simple "selection.cut" error. Office 2019
Novice
Help with debugging fairly simple "selection.cut" error.
 
Join Date: Aug 2023
Posts: 5
GDA63378 is on a distinguished road
Default

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.
Reply With Quote
  #4  
Old 08-12-2023, 03:31 PM
GDA63378 GDA63378 is offline Help with debugging fairly simple "selection.cut" error. Windows 10 Help with debugging fairly simple "selection.cut" error. Office 2019
Novice
Help with debugging fairly simple "selection.cut" error.
 
Join Date: Aug 2023
Posts: 5
GDA63378 is on a distinguished road
Default

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.
Reply With Quote
  #5  
Old 08-14-2023, 02:05 PM
GDA63378 GDA63378 is offline Help with debugging fairly simple "selection.cut" error. Windows 10 Help with debugging fairly simple "selection.cut" error. Office 2019
Novice
Help with debugging fairly simple "selection.cut" error.
 
Join Date: Aug 2023
Posts: 5
GDA63378 is on a distinguished road
Default

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.
Reply With Quote
Reply



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
Help with debugging fairly simple "selection.cut" error. Selection.Bookmarks("\headinglevel") WITHOUT Selection NobodysPerfect Word VBA 3 01-14-2015 12:58 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:23 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft