Date in DD/MM/YYYY format to input into excel's cells

Discussion, questions and support.
Post Reply
Marty123
Posts: 25
Joined: Apr 17th, ’22, 23:05

Post by Marty123 » Jul 23rd, ’22, 08:15

HI Marko, Hi Tom,

I like to key in the date in DD/MM/YYYY format in 2 cells of an excel worksheet. Here's my code.

Code: Select all

Inputbox, inputpath,, FPfile:,,200,120
Inputbox, inputpath2,, PHfile:,,200,120

Path := inputpath
Path2 := inputpath2


PHfile :=ComObjcreate("Excel.Application")
PHfile.visible := true
PHfile.Workbooks.Open(Path2)

FPfile:=ComObjcreate("Excel.Application")
FPfile.visible := True
FPfile.Workbooks.Open(Path)    


FPfile.WorkSheets("27_Signature").Range("B19:J20").value := %a_longdate%
FPfile.WorkSheets("27_Signature").Range("V34:AD36").value := %a_longdate%


PHfile.DisplayAlerts:=false
PHfile.Application.CutCopyMode:=False
PHfile.Workbooks.Close()
PHfile.quit()
PHfile:=""

FPfile.quit()

I tried a few variations fromthe system date variable, like a_MM, or a_longdate, and sometimes with or without the percentage sign, but always run into some kind of script error, or either the data was not properly rendered in excel (hit or miss, with partial characters or sometimes jibberish)

Can ask for your input? It will also be great if text expander strings can be used as value for these cells value.

Thanks in advance.
User avatar
Tom
Posts: 791
Joined: Nov 24th, ’15, 23:39

Post by Tom » Jul 23rd, ’22, 09:02

In Type: Command you can use AutoHotkey date and time variables:
https://www.autohotkey.com/docs/Variables.htm#date

Code: Select all

....value := A_MM "-" A_DD "-" A_YYYY
You could also use a FormatTime command:

Code: Select all

FormatTime, A_LongDate,, LongDate
....value := A_LongDate
Note that percent signs are not used in expressions with the := operator.
Marty123
Posts: 25
Joined: Apr 17th, ’22, 23:05

Post by Marty123 » Jul 23rd, ’22, 09:17

Thanks So much, Tom!
Post Reply