Hello, I'm completely new to KM since I've just purchased it. I would really appreciate if you guys can help me creating a macro because I tried with IA and it didn't work. Yeah... I know.
Open an Excel file (urls.xlsx).
Copy each line from Column A one by one.
Paste each line into Visual Studio Code’s terminal.
Wait 10 seconds between pastes.
Stop when all lines are done.
I honestly have been trying for almost 3 hours and at some point it worked but then it started pasting the lines from my xlsx outside the Visual Studio Code's Terminal and I had to stop.
Thank you in advance for any help and I'm sorry if this isn't the right place for that.
It would helpful if you could post your macro, that way we can see what you're working with and perhaps figure out why it might've stopped functioning as intended.
tell application "Microsoft Excel"
-- Abrir o arquivo Excel
open "/Users/joaquim/Downloads/api/urls.xlsx"
set planilha to active sheet of workbook "urls.xlsx"
-- Pegar todas as linhas da Coluna A
set ultimaLinha to first row index of (get end of range planilha direction toward the bottom)
set dadosColunaA to value of range ("A1:A" & ultimaLinha) of planilha
-- Fechar o Excel sem salvar
close workbook without saving
end tell
-- Processar cada linha
repeat with linhaAtual in dadosColunaA
set codigo to contents of linhaAtual
-- Colar no terminal do VS Code
tell application "Visual Studio Code" to activate
delay 1 -- Esperar o VS Code abrir
-- Simular teclas para colar e pressionar Enter
tell application "System Events"
keystroke codigo -- Cola o texto diretamente
keystroke return -- Pressiona Enter
end tell
delay 10 -- Esperar 10 segundos entre linhas
end repeat
This is AppleScript -- do have an actual macro, or is the macro just a wrapper for this script?
If you want to troubleshoot an AppleScript, better to do so in the Script Editor application -- that way you'll see a more meaningful error message. I'm guessing it'll tell you there's an error with get end of range (Line 7) -- but even after you fix that, your code isn't setting the Clipboard for each item you want to paste.
But why use AppleScript at all? If you do want to do this with all the values in column A it's easy enough with Keyboard Maestro actions because you can do the selection with keystrokes: