openpyxl active cell cant copy cell

5 viewsexcelopenpyxlpyautoguipython
0

I need help with a problem I’ve been having for a while.

I’m creating an automation that copies information from Excel to another application (like Notepad).

At first, I was using Pyautogui to copy and paste, but after a while, it started to fail. Sometimes, it wouldn’t copy correctly or wouldn’t even press the copy key.

So, I decided to try using Openpyxl to copy just the cell. But I’m having trouble getting it to work.

First, I’m not able to get the cell value correctly. Second, I can’t make the automation recognize in real time that the active cell has been changed.

there is the code:

import openpyxl

while True:

   wb = openpyxl.load_workbook('CONEMB_ZLE.xlsx')

   sheet = wb.active
   cell = sheet.active_cell  # Get the active cell object

   print(cell)

   wb.save('CONEMB_ZLE')
   print('salvo')
   wb.close()

Can anyone help me with this?

Thanks in advance!

tried everithing but idk i just need to copy a focused cell and save into a var