I’m from Brazil and I want to run a macro that extract PDF of BR Invoices.
I have no much experience but I think I’m almost there…
The code read first line of CSV, run the task correctly but dont jump to the next lines using WHILE.
Anyone could help me?
{
“Name”: “EmiteNotasFinal-1”,
“CreationDate”: “2025-2-11”,
“Commands”: [
{
“Command”: “csvRead”,
“Target”: “readcsvtestdata.csv”,
“Value”: “”,
“Description”: “Initial CSV read”
},
{
“Command”: “store”,
“Target”: “${!csvReadMaxRow}”,
“Value”: “totalLinhas”,
“Description”: “Store total number of rows”
},
{
“Command”: “store”,
“Target”: “1”,
“Value”: “!csvLine”,
“Description”: “Initialize CSV line counter”
},
{
“Command”: “echo”,
“Target”: “Total de linhas: ${totalLinhas}”,
“Value”: “”,
“Description”: “Debug: Display total rows”
},
{
“Command”: “executeScript”,
“Target”: “document.body.insertAdjacentHTML(‘beforeend’, ‘<div id=\"uivision-alert\" style=\"position:fixed;top:50px;left:50%;transform:translate(-50%, 0);background-color:red;color:white;padding:20px;border-radius:10px;z-index:9999;font-size:18px;font-weight:bold;text-align:center;width:60%;max-width:400px;box-shadow:0px 0px 10px rgba(0,0,0,0.5);\">A macro funciona somente em TELA CHEIA - F11’); setTimeout(function() { document.getElementById(‘uivision-alert’).remove(); }, 5000);”,
“Value”: “”,
“Description”: “Fullscreen alert”
},
{
“Command”: “pause”,
“Target”: “5000”,
“Value”: “”,
“Description”: “Pause after popup”
},
{
“Command”: “while_v2”,
“Target”: “${!csvLine} <= ${totalLinhas}”,
“Value”: “”,
“Description”: “Continue while there are rows to process”
},
{
“Command”: “csvRead”,
“Target”: “readcsvtestdata.csv”,
“Value”: “${!csvLine}”,
“Description”: “Read current line from CSV”
},
{
“Command”: “store”,
“Target”: “${!COL1}”,
“Value”: “apelido”,
“Description”: “Store column 1 value”
},
{
“Command”: “store”,
“Target”: “${!COL2}”,
“Value”: “sigla”,
“Description”: “Store column 2 value”
},
{
“Command”: “store”,
“Target”: “${!COL3}”,
“Value”: “descricao”,
“Description”: “Store column 3 value”
},
{
“Command”: “store”,
“Target”: “${!COL4}”,
“Value”: “valor”,
“Description”: “Store column 4 value”
},
{
“Command”: “echo”,
“Target”: “Processando linha ${!csvLine}: Apelido=${apelido}, Sigla=${sigla}”,
“Value”: “”,
“Description”: “Debug current row”
},
{
“Command”: “open”,
“Target”: “Nota do Milhão”,
“Value”: “”,
“Description”: “Open invoice page”
},
{
“Command”: “executeScript”,
“Target”: “var linhaAtual = Number(${!csvLine}); var totalLinhas = Number(${totalLinhas}); document.body.insertAdjacentHTML(‘beforeend’, '<div id=\"uivision-contagem\" style=\"position:fixed;top:20px;left:50%;transform:translate(-50%, 0);background-color:blue;color:white;padding:10px;border-radius:10px;z-index:9999;font-size:16px;font-weight:bold;text-align:center;width:50%;max-width:300px;box-shadow:0px 0px 10px rgba(0,0,0,0.5);\">Emitindo nota ’ + linhaAtual + ’ de ’ + totalLinhas + ‘’); setTimeout(function() { document.getElementById(‘uivision-contagem’).remove(); }, 3000);”,
“Value”: “”,
“Description”: “Progress popup”
},
{
“Command”: “pause”,
“Target”: “3000”,
“Value”: “”,
“Description”: “Pause after popup”
},
{
“Command”: “click”,
“Target”: “id=ctl00_body_ddlApelido”,
“Value”: “”,
“Description”: “Click nickname dropdown”
},
{
“Command”: “pause”,
“Target”: “2000”,
“Value”: “”,
“Description”: “Wait for dropdown”
},
{
“Command”: “select”,
“Target”: “id=ctl00_body_ddlApelido”,
“Value”: “label=${apelido}”,
“Description”: “Select nickname”
},
{
“Command”: “click”,
“Target”: “id=ctl00_body_btAvancar”,
“Value”: “”,
“Description”: “Click advance button”
},
{
“Command”: “type”,
“Target”: “id=ctl00_body_tbValor”,
“Value”: “${valor}”,
“Description”: “Enter value”
},
{
“Command”: “pause”,
“Target”: “2000”,
“Value”: “”,
“Description”: “Pause before description”
},
{
“Command”: “type”,
“Target”: “id=ctl00_body_tbDiscriminacao”,
“Value”: “${descricao}”,
“Description”: “Enter description”
},
{
“Command”: “visualAssert”,
“Target”: “emitir.png”,
“Value”: “”,
“Description”: “Check for emit button”
},
{
“Command”: “XClick”,
“Target”: “emitir.png”,
“Value”: “”,
“Description”: “Click emit button”
},
{
“Command”: “pause”,
“Target”: “2000”,
“Value”: “”,
“Description”: “Pause before confirmation”
},
{
“Command”: “XType”,
“Target”: “${KEY_ENTER}”,
“Value”: “”,
“Description”: “Confirm emission”
},
{
“Command”: “visualAssert”,
“Target”: “nfse.png”,
“Value”: “”,
“Description”: “Check for NFSe button”
},
{
“Command”: “XClick”,
“Target”: “nfse.png”,
“Value”: “”,
“Description”: “Click NFSe button”
},
{
“Command”: “visualAssert”,
“Target”: “imprimir.png”,
“Value”: “”,
“Description”: “Check for print button”
},
{
“Command”: “XClick”,
“Target”: “imprimir.png”,
“Value”: “”,
“Description”: “Click print button”
},
{
“Command”: “visualAssert”,
“Target”: “nome.png”,
“Value”: “”,
“Description”: “Check for name field”
},
{
“Command”: “XType”,
“Target”: “${sigla}.pdf”,
“Value”: “”,
“Description”: “Enter PDF filename”
},
{
“Command”: “XType”,
“Target”: “${KEY_ENTER}”,
“Value”: “”,
“Description”: “Confirm save”
},
{
“Command”: “storeEval”,
“Target”: “${!csvLine} + 1”,
“Value”: “!csvLine”,
“Description”: “Increment CSV line counter”
},
{
“Command”: “echo”,
“Target”: “Próxima linha: ${!csvLine}”,
“Value”: “”,
“Description”: “Debug next line”
},
{
“Command”: “endWhile”,
“Target”: “”,
“Value”: “”,
“Description”: “End while loop”
},
{
“Command”: “executeScript”,
“Target”: “document.body.insertAdjacentHTML(‘beforeend’, ‘<div id=\"uivision-alert-final\" style=\"position:fixed;top:50%;left:50%;transform:translate(-50%, -50%);background-color:green;color:white;padding:40px;border-radius:10px;z-index:9999;font-size:24px;font-weight:bold;text-align:center;width:80%;max-width:600px;box-shadow:0px 0px 10px rgba(0,0,0,0.5);\">FINISH!’);”,
“Value”: “”,
“Description”: “Final success message”
}
]
}