cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Entering date by script - runtime error 613 in vba

Former Member
0 Likes
6,068

Hi Team,

I am trying to automize a report in ME2M, where I have to pull a monthly report, from the first day of the previous month until the last days of the same month. I am facing issues when entering the date - neither the upload from clipboard nor referencing to a cell in the workbook works. I receive runtime error 613. Can you please help me in resolving this issue?

The variable defined:

Dim firstday As Date

Dim lastday As Date

firstday = DateSerial(Year(Date), Month(Date) - 1, 1)

lastday = DateSerial(Year(Date), Month(Date), 0)

And the script where the runtime error occurs:

session.findById("wnd[0]/usr/ctxtS_BEDAT-LOW").Text = Sheet("Plants").Range("C1").Value

session.findById("wnd[0]/usr/ctxtS_BEDAT-HIGH").Text = Sheet("Plants").Range("D1").Value

If I put "01062018" instead of e.g. Sheet("Plants").Range("C1").Value the scrip runs perfectly, somehow cell referencing gives the issue..

Thanks in advance!

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

Hey, in the meantime I found the solution - even simpler then referencing to the cell in Excel. The root-issue was with the date format. The date format in my SAP is dd.mm.yyy, thus I had to insert the VBA date variable this way:

session.findById("wnd[0]/usr/ctxtS_BEDAT-LOW").Text = Format(DateSerial(Year(Date), Month(Date) - 1, 1), "dd.mm.yyyy") session.findById("wnd[0]/usr/ctxtS_BEDAT-HIGH").Text = Format(DateSerial(Year(Date), Month(Date), 0), "dd.mm.yyyy")

Hope it helps you, I've been struggling with it for 2 days...:D

Cheers,

Bea

Answers (0)