Hi!
I have a configuration file (.xlsx) where I have put in Client, project number and a date (as a custom iproperty). These cells are linked to the iProperties in the IDWs. The project number and client works well, however im struggling with the date. The date is written dd.mm.yyyy in excel, and Date1 is set to date type.
Date1 = GoExcel.CellValue(ThisDoc.Path & "\Project configuration.xlsx", "Sheet1", "D4")
When I run the rule Date1 changes type from Date to Number, and inserts a random number.
By inserting this code:
Date1 = DateString()
The date is converted to mm-dd-yyyy, but with wrong dates. If I write 15.10.2013 in Excel it will write the date as 08-01-2013. How to get it written lik 15.10.2013?
Cheers!
Have you tried the SAVE AS option and saved the file as XLS format instead of xlsx and the tested it?
You may also get a bit more help by posting your question here http://answers.microsoft.com/en-us/office
Last time I saw this question this setting worked for the user. Maybe this will work for you as well.
Go to control panel here.
I know this is a global setting, but maybe through your routine you can tap into this setting.
If this solved your issue please mark this posting "Accept as Solution".
Or if you like something that was said and it was helpful, Kudos are appreciated. Thanks!!!!
Cadmanto is correct, Inventor reads the date format from the Windows region and date settings in the O/S and not any value/setting withing Inventor.
Hi 128848,
Since you're using code to handle the date, you can format the date as needed. Here's a quick example:
Dim Date1 As Date
Date1 = GoExcel.CellValue(ThisDoc.Path & "\Project configuration.xlsx", "Sheet1", "D4")
Dim MyDate As String
MyDate = Format(Date1, "dd.MM.yyyy")
MessageBox.Show(MyDate , "iLogic")
Also just as a tip, you can search and ask programming questions of this type on the Inventor Customization forum too:
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Got an error trying out your code Curtis.
Error on Line 14 : Argument not specified for parameter 'format' of 'Public Shared Function Format(enumType As System.Type, value As Object, format As String) As String'.
Error on Line 14 : Value of type 'Date' cannot be converted to 'System.Type'.
The setting in the control panel is set to dd.MM.yyyy.
DateTime.Now.ToString("d")
This will give me correct format of the date, but I its not todays date I want to write. Tried to insert a parameter instead of Now, but that did`nt work. Any ideas?
Hi 128848,
Is it possible that the cell format in the Excel file is causing issues? If so, maybe converting the cell value to a string first, and then converting it to a date is what is needed?
'bring in the date from Excel as a string Dim Date1 As String Date1 = GoExcel.CellValue(ThisDoc.Path & "\Project configuration.xlsx", "Sheet1", "D4") 'convert string to date Dim Date2 As Date Date2 = Date1 'format date MyDate = Format(Date2, "dd.MM.yyyy") 'display date to user MessageBox.Show(MyDate , "iLogic")
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Well, this is akward.
The cell was formated as date, with the correct format. Changed it to text, and everything works fine, however im not converting it to a date. Just as a string and everything is in order.
Thanks for everybody´s time and comments 🙂