Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
G'day to all,
I have an Excel 97 macro which imports csv data, including dates in dd/mm/yyyy format, and would like to be able to use it with both Excel 97 and Excel 2003. When I ran it in XL2003 some dates were imported in the wrong format, and on checking the MS Knowledgebase (911759) I found that it's a known problem. The workaround is to add 'Local:=True' to the import code. So my code for XL2003 now looks like this: Workbooks.OpenText FileName:="C:\temp\" & MyStockCSV, Origin:=xlWindows, _ StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, Comma:=True, _ Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2, 5), _ Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1)), Local:=True Works fine in XL2003, but XL97 doesn't like the 'local', and gives a "Compile error: Named argument not found" message. I thought I could overcome it by checking for the version, but the following code that I tried doesn't work. Before it actually runs I get the same message as above. If Val(Left(Application.Version, 3)) = 8# Then ' Excel 97 is running Workbooks.OpenText FileName:="C:\temp\" & MyStockCSV, Origin:=xlWindows, _ StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, Comma:=True, _ Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2, 5), _ Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1)) Else Workbooks.OpenText FileName:="C:\temp\" & MyStockCSV, Origin:=xlWindows, _ StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, Comma:=True, _ Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2, 5), _ Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1)), Local:=True End If I expected that if the macro was being used in XL97 then the first Workbooks.Open line would run, and then exit the If construct. However, that doesn't appear to be the case. Could someone suggest how the code can be modified so that it will run in both XL97 and XL2003. Regards, John |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Modify a Macro | Excel Worksheet Functions | |||
Help Required!!! Macro to load data from version 1 to version 2 | Excel Worksheet Functions | |||
How to modify a copy macro | Excel Worksheet Functions | |||
Recover earlier version of excel sheet after new version saved? | Excel Discussion (Misc queries) | |||
How do I modify a row depending upon what a cell value is? | Excel Worksheet Functions |