Help with Excel Copy Paste File Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ConfusedatWork2
Posts: 12
Joined: 18 Nov 2021, 16:02

Help with Excel Copy Paste File

Post by ConfusedatWork2 » 26 Nov 2021, 14:59

I have the below code from AHK V1 I believe... I want to be able to put in some stops, or waits, and also if there is anohter option to grab all my cells in excel to a clipboard of somesort? Maybe that might be easier? ANy help on the bottom data would be greatly appreciated.


Code: Select all

else If A_ThisMenuItem=Settlements
{
setkeydelay 2


Loop, 10
{
WinActivate   Settlements - Excel ahk_class XLMAIN
Send {f2}
Send {shift down}{home}{Shift up}
Send ^c
Sleep 25
Send {Enter}

Sleep 1000

Winactivate,    Program-Production ahk_class FNWND3170
Click 721 194 ;; Reprint One Settlement
Send {shift down}{left 10}{shift up}
Send {delete}
Sleep 500

Send ^v


Sleep 1000
Click 144 71 ;; Run
Sleep 3000

Winactivate  Save Print Output As ahk_class #32770
Sleep 100
Send ^v


Send {Enter}



}

Return
}

User avatar
mikeyww
Posts: 26883
Joined: 09 Sep 2014, 18:38

Re: Help with Excel Copy Paste File

Post by mikeyww » 26 Nov 2021, 16:03

This may help with some ideas for copying & pasting. viewtopic.php?f=76&t=83452

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

Re: Help with Excel Copy Paste File

Post by flyingDman » 26 Nov 2021, 16:29

That example is primarily for copying data from one excel range to another. To copy to the clipboard (for use in another app), you can use this:

Code: Select all

xl := ComObjActive("excel.application")
xl.range("C:C").copy							;assuming column C or xl.activecell.EntireColumn.Copy
msgbox % clipboard := trim(clipboard,"`r`n")
14.3 & 1.3.7

FCGaston
Posts: 1
Joined: 26 Nov 2021, 16:34

Re: Help with Excel Copy Paste File

Post by FCGaston » 26 Nov 2021, 17:01

mikeyww wrote:
26 Nov 2021, 16:03
This may help with some ideas for copying & pasting. viewtopic.php?f=76&t=83452
Hola buenas tardes! soy Gaston de Argentina y estoy empezando a incursionar en Pulover's Macro Creator y necesito saber como podría hacer para copiar celda por celda de un rango definido de un archivo de excel e ir pegando en celdas de otro programa? Gracias

Hello good afternoon! I'm Gaston from Argentina and I'm starting to dabble in Pulover's Macro Creator and I need to know how I could copy cell by cell from a defined range of an excel file and paste into cells from another program? Thanks

ConfusedatWork2
Posts: 12
Joined: 18 Nov 2021, 16:02

Re: Help with Excel Copy Paste File

Post by ConfusedatWork2 » 29 Nov 2021, 10:23

Is there a way to wait for programs before starting the commands?

For example:
This one will pop up when the system has created the file to save and could be delayed.

Code: Select all

Winactivate,  Print to PDF Document - Foxit PDF Editor Printer ahk_class #32770

This one is always open

Code: Select all

Winactivate,    Agrosoft-Production ahk_class FNWND3170
This one is always open

Code: Select all

WinActivate,   Settlements - Excel ahk_class XLMAIN

ConfusedatWork2
Posts: 12
Joined: 18 Nov 2021, 16:02

Re: Help with Excel Copy Paste File

Post by ConfusedatWork2 » 29 Nov 2021, 10:24

mikeyww wrote:
26 Nov 2021, 16:03
This may help with some ideas for copying & pasting. viewtopic.php?f=76&t=83452


Is there a way to wait for specific programs to launch..?
This one could be 1 second, or 15 seconds... and then causes an error.

Code: Select all

Sleep 5000

Winactivate,  Print to PDF Document - Foxit PDF Editor Printer ahk_class #32770
Sleep 100
Send ^v

User avatar
mikeyww
Posts: 26883
Joined: 09 Sep 2014, 18:38

Re: Help with Excel Copy Paste File

Post by mikeyww » 29 Nov 2021, 10:44


ConfusedatWork2
Posts: 12
Joined: 18 Nov 2021, 16:02

Re: Help with Excel Copy Paste File

Post by ConfusedatWork2 » 30 Nov 2021, 09:36

mikeyww wrote:
29 Nov 2021, 10:44
:arrow: WinWait

And that replaces Winactivate?

User avatar
mikeyww
Posts: 26883
Joined: 09 Sep 2014, 18:38

Re: Help with Excel Copy Paste File  Topic is solved

Post by mikeyww » 30 Nov 2021, 09:50

Yes, and sleep is not needed. An example is below.

Code: Select all

EnvGet, pf86, ProgramFiles(x86)
PDFapp = %pf86%\Foxit Software\Foxit PDF Editor\FoxitPDFEditor.exe
pdf    = test.pdf
Run, %PDFapp% "%pdf%"
WinWaitActive, ahk_class classFoxitPhantom ahk_exe FoxitPDFEditor.exe,, 5
If ErrorLevel {
 MsgBox, 48, Error, An error occurred while waiting for the window. Aborting.
 Return
}
Send ^p
You may want some extra code to see whether the program is already open or is already active.

Post Reply

Return to “Ask for Help (v1)”