0

I have a very specific question. The line:

expform_ws.Range("Total").Offset(-1, 0).EntireRow.Insert

in the code below is not working:

# Write data in expenses form
expform_wb = xl.Workbooks.Open(expform_path, Editable=True)
expform_ws = expform_wb.Worksheets('Expense Form')
last_row_ef = expense_items + 15

expform_ws.Range("Total").Offset(-1, 0).EntireRow.Insert
expform_ws.Range('Casecode').Value = case_code
expform_ws.Range('D6').Value = name
expform_ws.Range('D7').Value = last_name
expform_ws.Range('D8').Value = datetime.date.today().strftime("%d/%m/%Y")
expform_ws.Range('B16:B' + str(last_row_ef)).Value = date
expform_ws.Range('D16:D' + str(last_row_ef)).Value = descr

In case this helps: the line gets highlighted in PyCharm as "Statement seems to have no effect".

Anyone can help to spot what I am doing wrong?

Thanks!

3
  • expform_ws.Range("Total").Offset(-1, 0).EntireRow.Insert this indeed doesnt do anything, im no familiar with win32com specifically, but i think you are missing the () at the end of that line to actually call the function Commented Mar 17, 2019 at 12:51
  • @Nullman, you are right! I was missing that. Now it works. How stupid... Commented Mar 17, 2019 at 12:58
  • very common oversight, don't worry about it Commented Mar 17, 2019 at 12:58

1 Answer 1

2

In this line

expform_ws.Range("Total").Offset(-1, 0).EntireRow.Insert

You aren't actually CALLING the function, you are just getting "reference" to it, add () to call it

expform_ws.Range("Total").Offset(-1, 0).EntireRow.Insert()
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.