X 1 Loop??? Copy and paste list help.

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Ribsnatcher
Posts: 1
Joined: 15 Sep 2021, 20:15

X 1 Loop??? Copy and paste list help.

Post by Ribsnatcher » 15 Sep 2021, 20:22

I'm trying to copy text from a excel row and create a list on notepad, how do I loop it so that at the start of the process of it goes down to the next row, till it gets to the bottom of the list? I would really appreciate the help.

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

Re: X 1 Loop??? Copy and paste list help.

Post by flyingDman » 15 Sep 2021, 21:50

The way to interact with Excel is by using COM. There are various tutorials about COM / Excel on the forum. Here is a list:
https://autohotkey.com/board/topic/69033-basic-ahk-l-com-tutorial-for-excel/
viewtopic.php?f=7&t=8978
viewtopic.php?f=6&t=77#p495
also look at:
https://docs.microsoft.com/en-us/office/vba/api/overview/excel
https://github.com/ahkon/MS-Office-COM-Basics/tree/master/Examples/Excel
The simplest script to accomplish what your are describing is:

Code: Select all

xl := ComObjActive("excel.application")      ; connect to the open Excel applcation
for c in xl.range("B:B")			         ; loop through column B
	if !c.value 							 ; if the current cell is empty break the loop
		break
	else									 ; if not...
		lst .= c.value "`n"					 ; add the cell value to a variable and add a new line 

msgbox % lst		                         ; show the list (could be send % lst)
14.3 & 1.3.7

Post Reply

Return to “Ask for Help (v1)”