CutCopyMode not working

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
zvit
Posts: 224
Joined: 07 Nov 2017, 06:15

CutCopyMode not working

Post by zvit » 07 Aug 2022, 11:31

When I paste data into Excel cells with AHK, those cells are selected. I need to unselect them. I tried xlApp.Application.CutCopyMode := False, but it doesn't work. Any ideas?

User avatar
boiler
Posts: 16926
Joined: 21 Dec 2014, 02:44

Re: CutCopyMode not working

Post by boiler » 07 Aug 2022, 11:42

Why do they need to be unselected? But if you insist, select another cell. At least one cell will always be selected.

.CutCopyMode := False doesn't uneselect cells. It takes them out of cut/copy mode, and pasted cells aren't in that state in the first place.

User avatar
zvit
Posts: 224
Joined: 07 Nov 2017, 06:15

Re: CutCopyMode not working

Post by zvit » 07 Aug 2022, 12:37

Need to unselect because when I run the script a second time with new data, I get an error because the previous cells are selected.
Yes, that's my workaround for now, to select something else. XL_Select_Range(xlApp,"A1:A1") (using Joe Glines XL.ahk)

User avatar
flyingDman
Posts: 2817
Joined: 29 Sep 2013, 19:01

Re: CutCopyMode not working

Post by flyingDman » 07 Aug 2022, 12:51

You're not telling us how you copy and paste. Are you using:

Code: Select all

xl.range("G6:G8").copy(xl.range("M6:M8"))
or

Code: Select all

xl.range("G6:G8").copy
xl.activesheet.paste(xl.range("M6"))
or

Code: Select all

xl.range("G6:G8").copy
xl.activesheet.Range("M6").PasteSpecial(-4104)
As far as I know only the last method leaves the target range selected.
And, BTW, you do not need a "wrapper" function to select a range:

Code: Select all

xl.range("a1").select
See here https://docs.microsoft.com/en-us/office/vba/api/excel.range.select
14.3 & 1.3.7

User avatar
zvit
Posts: 224
Joined: 07 Nov 2017, 06:15

Re: CutCopyMode not working

Post by zvit » 07 Aug 2022, 13:21

I copy the Clipboard data outside Excel and paste it into my script after running code on it.
Correct about the wrapper, I guess I can use xlApp.Sheets("MAIN-WORDS").Range("A1").Select. I'm just familiar with the XL libraries.

User avatar
flyingDman
Posts: 2817
Joined: 29 Sep 2013, 19:01

Re: CutCopyMode not working

Post by flyingDman » 07 Aug 2022, 13:24

That's the issue with these wrappers. You forget the original functionality...
14.3 & 1.3.7

User avatar
boiler
Posts: 16926
Joined: 21 Dec 2014, 02:44

Re: CutCopyMode not working

Post by boiler » 07 Aug 2022, 13:34

And to me, this wrapper doesn't really simplify anything. It just seems like needing to memorize different syntax that is at least as complex as the native syntax that is being wrapped.

User avatar
zvit
Posts: 224
Joined: 07 Nov 2017, 06:15

Re: CutCopyMode not working

Post by zvit » 07 Aug 2022, 13:50

boiler wrote:
07 Aug 2022, 13:34
And to me, this wrapper doesn't really simplify anything. It just seems like needing to memorize different syntax that is at least as complex as the native syntax that is being wrapped.
You're probably right, but since I have the XL.ahk loaded, I just type "XL_" and I get a popup showing me all the available functions.

Post Reply

Return to “Ask for Help (v1)”