compare a cell value with values of cells from another workbook

hi evrybody,

I am quite new to AS. What I want is to ask the user for inputing a date. Then, I want to compare the date with the current date. In the following piece of code, it seems that mydate is not defined. Can anybody help ?

tell application “Microsoft Excel”
activate
set thedate to display dialog “enter date” default button “OK” default answer “”
set answer to text returned of thedate

set mydate to date answer
set current_date to current date

if current_date > mydate then
	display dialog current_date
else
	display dialog mydate
end if

end tell

Thanks

Hi,

the format of the entered date must be one of the specified date formats in System Preferences > International > Formats
Here are some lines of code to check the format


repeat
	set thedate to display dialog "enter date" default button "OK" default answer ""
	set answer to text returned of thedate
	try
		set mydate to date answer
		mydate
		exit repeat
	on error
		tell (current date) to set timeString to short date string & space & time string
		display dialog "enter date with format " & return & timeString
	end try
end repeat
set current_date to current date

if current_date > mydate then
	display dialog current_date as text
else
	display dialog mydate
end if

Hi SefanK,

Sorry to say that it does not work. I run the script and I am asked to input a date with this format dd/mm/aa hh:mm:ss. And it asks it again an again which means that there is always an error. Don’t you think that the problem still comes from the expression

		set mydate to date answer
		mydate

Pongocito

hm, of course I’ve tested the script and it works on my machine (10.5.6).

I had two kinds of errors while testing:
¢ the error is thrown immediately
¢ the variable wasn’t defined, the error occured in the line mydate

I can confirm that the erro I have is that mydate is not defined. My OS version is the same.