get save date

get save date

martinhoos
Advocate Advocate
732 Views
11 Replies
Message 1 of 12

get save date

martinhoos
Advocate
Advocate

Hello,

i like to show via "MessageBox.Show" the date of cell H3 (Excel).

 

If i go with this code:

 

myCell = GoExcel.CellValue(myXLS, "Sheet1", "H3")
MessageBox.Show("the date:" & " " & myCell,"iLogic")

 

i get the result: 42957  instead of 14.08.2017.  This wont work!

 

 

Is it possible, Instead of the above code, to show the savedate of the Excel file with the right date 14.08.2017?

 

Thanks for your help.

 

Regards Martin

0 Likes
Accepted solutions (1)
733 Views
11 Replies
Replies (11)
Message 2 of 12

b_sharanraj
Advocate
Advocate

hi @martinhoos

 

Change the Format of H3 Cell from Date to General in Excel and try once 🙂

 

Regards

B.Sharan Raj

0 Likes
Message 3 of 12

martinhoos
Advocate
Advocate

Hi Sharan,

thank you for your reply... thats too easy - the Excel file is generated by an automatic process. Change this cell by hand runs out of the routine/code.

All changes or input should come out of the code.

Regards Martin

0 Likes
Message 4 of 12

b_sharanraj
Advocate
Advocate

Is Excel generated by Inventor or some other Excel via Macros or External Apps?

 

Is H3 Cell is formula like "=Today() " or Value like 14.08.2017?

Regards

B.Sharan Raj

0 Likes
Message 5 of 12

martinhoos
Advocate
Advocate

Hi Sharan,

thx for reply. The file is generated via external app. The format is like:  14.08.2017

Regards Martin

0 Likes
Message 6 of 12

Anonymous
Not applicable

What is the format of the cell in excel? Is the entry in cell H3 exactly written as 14.08.2017  ???

I did a quick test and it returns exactly as it is in excel

0 Likes
Message 7 of 12

martinhoos
Advocate
Advocate

Hi Craig,

thx for your reply. Pls look at the pic.

 

date.JPG

 

 

 

Regards Martin

 

0 Likes
Message 8 of 12

Anonymous
Not applicable

I don't have the same options as you do in my excel cel format (see attachment). But this is the code I tried and I attached a picture of the resulting msg box

myCell = GoExcel.CellValue(myXLS, "Sheet1", "A1")

MessageBox.Show(myCell, "Title")

 

What version of excel are you using? Perhaps try this line instead:

 

Dim myCell As Date = GoExcel.CellValue(myXLS, "Sheet1", "A1")

 

0 Likes
Message 9 of 12

b_sharanraj
Advocate
Advocate
Hi Martin

You need to try once what Mr.Henderson suggested still if it's not working we have to Change the Format Data of the cell while it's generating from your External App


Regards

B.Sharan Raj

0 Likes
Message 10 of 12

martinhoos
Advocate
Advocate

Hi Craig,

the result of the first solution:  42961

 

If i try

 

Dim myCell As Date = GoExcel.CellValue(myXLS, "Sheet1", "A1")

i get an error:

 

 

mycell.JPG

 

I use Excel 2010

 

Thx for your help!

 

Regards Martin

0 Likes
Message 11 of 12

b_sharanraj
Advocate
Advocate
Accepted solution

Hi @martinhoos

 

Try this

 

myCell = DateTime.FromOADate(GoExcel.CellValue(myXLS, "Sheet1", "A1"))

Regards

B.Sharan Raj

Message 12 of 12

martinhoos
Advocate
Advocate

Hello Sharan,

thats it! Your code works...

Thank you very much...

Regards Martin

0 Likes