Hi,
i will import a time from a Excel Cell.
First problem is:
like this
XLGetCell>xlBook,InputVar,1,9,InputTime
The value of this cell ist 22:00:00 (hs european time)
But, after the import .... Macroshedu.. lose the format and so i recive the value inside the variable 0.916666666666667.
How can i do, that i have not 0.916666666666667?
I need this format hs
Second one is,
if i close with
XLQuit>xlBook
but the Excel (process) is open and will not be close!
I only can close the process with the killproce... command... but i think thats not the fine and right way
great thanks for your help
Import a time from Excel
Moderators: Dorian (MJT support), JRL
Hi Ghost24de,
Here is some early feedback on what "may be" happening there and an idea on how you could convert 0.916666666666667 back to 22:00:00
I notice that...
22/24 = 0.91666666666666666666666666666667
So...
1/24 = 1 hour = 0.041666666666666666666666666666667
- in a loop, count how many times you can subtract 0.0416 from total, that is hours value
(1/60)/24 = 1 min = 0.00069444444444444444444444444444444
- in a loop, count how many times you can subtract 0.000694 from remainder above, that is min value
((1/60)/60)/24 = 1 sec = 0.000011574074074074074074074074074074
- in a loop, count how many times you can subtract 0.0000115740 from remainder above, that is sec value
- now that you have hr, min and sec values, build a string using those values separated by colons :
And now someone will post an easier way... take it away...
Here is some early feedback on what "may be" happening there and an idea on how you could convert 0.916666666666667 back to 22:00:00
I notice that...
22/24 = 0.91666666666666666666666666666667
So...
1/24 = 1 hour = 0.041666666666666666666666666666667
- in a loop, count how many times you can subtract 0.0416 from total, that is hours value
(1/60)/24 = 1 min = 0.00069444444444444444444444444444444
- in a loop, count how many times you can subtract 0.000694 from remainder above, that is min value
((1/60)/60)/24 = 1 sec = 0.000011574074074074074074074074074074
- in a loop, count how many times you can subtract 0.0000115740 from remainder above, that is sec value
- now that you have hr, min and sec values, build a string using those values separated by colons :
And now someone will post an easier way... take it away...
jpuziano
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -
....
mhhh
is ther noone ... with a idea from a easier way?
mhh i think .. i will splitt the excel cell into 3 single cells.. so one for the hour, one for the min and one for the sec... so i must import 3 values, but i think it is easier to go this way to write a loop and counter inside the makro.
And for the second answer... with the close porblem from excel?
is ther noone ... with a idea from a easier way?
mhh i think .. i will splitt the excel cell into 3 single cells.. so one for the hour, one for the min and one for the sec... so i must import 3 values, but i think it is easier to go this way to write a loop and counter inside the makro.
And for the second answer... with the close porblem from excel?
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
When you use XLGetCell it always will return the VALUE. The formatting is handled by Excel. You are seeing the raw data.
What you can do is use VBScript's FormatDateTime function to format the time the way you want it:
VBEval>FormatDateTime(0.916666666666667,3),formattedTime
MessageModal>formattedTime
So you could use this with XLGetCell:
XLGetCell>xlBook,InputVar,1,9,InputTime
VBEval>FormatDateTime(%InputTime%,3),formattedTime
MessageModal>formattedTime
What you can do is use VBScript's FormatDateTime function to format the time the way you want it:
VBEval>FormatDateTime(0.916666666666667,3),formattedTime
MessageModal>formattedTime
So you could use this with XLGetCell:
XLGetCell>xlBook,InputVar,1,9,InputTime
VBEval>FormatDateTime(%InputTime%,3),formattedTime
MessageModal>formattedTime
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
This works for me:
XLOpen>%USERDOCUMENTS_DIR%\book1time.xlsx,1,xlH
XLGetCell>xlH,Sheet1,1,1,theTime
VBEval>FormatDateTime(%theTime%,3),result
I tried it with cell A1 formatted to Time, of Type: hh:mm:ss like so:
If it isn't working for you can you share what format you are using.
XLOpen>%USERDOCUMENTS_DIR%\book1time.xlsx,1,xlH
XLGetCell>xlH,Sheet1,1,1,theTime
VBEval>FormatDateTime(%theTime%,3),result
I tried it with cell A1 formatted to Time, of Type: hh:mm:ss like so:
If it isn't working for you can you share what format you are using.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?