Skip to content

Instantly share code, notes, and snippets.

@DaneWeber
Last active April 7, 2016 17:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save DaneWeber/10162893 to your computer and use it in GitHub Desktop.
Save DaneWeber/10162893 to your computer and use it in GitHub Desktop.
Literal paste of tabular data into Excel via AHK hotkey
#z:: ; Text–only paste from ClipBoard
KeyWait, LWin
KeyWait, RWin
Clip0 = %ClipBoardAll% ; Save formatted text for later
ExcelBound = %Clipboard%
Loop, parse, ExcelBound, `r`n
{
if A_LoopField =
continue
nonemptyline := A_LoopField
Loop, parse, nonemptyline, `t
{
Clipboard = %A_LoopField%
Sleep 50
Send ^v
Send {tab}
}
Send {enter}
}
Sleep 50
ClipBoard = %Clip0% ; Restore original ClipBoard
VarSetCapacity(Clip0, 0) ; Free memory
Return
@DaneWeber
Copy link
Author

When you copy and paste in Excel with hidden columns, Excel brings over data you can't see. This AHK script pastes each cell individually in order to avoid any hidden data transfer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment