ranjitc
4/7/2016 - 5:03 PM

Literal paste of tabular data into Excel via AHK hotkey

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