Thanks Simon
But that was one of the first things I did: it doesn't work.
When you open the CSV file in Excel the quote is visible in the cells.
You have to click every single cell separately, click in the formulebar and
then Enter.
Users are not prepared to do that, because they sometimes export over 10000
lines.
Of course they also could make use of Excel functions like =TEXT(), but that
is no option for them.
I even tryed to export that Excel-function but there the parameter
separators mess everything up.
--
ICT
[quoted text, click to view] "Simon Whale" wrote:
> if you want to use CSV files, try putting a single quote before the number.
>
> e.g. '01234567
>
> Hope it Helps
> Simon
>
> "Optimo" <Optimo@discussions.microsoft.com> wrote in message
> news:9583B3D9-D680-42E9-BC3E-213C80EE8AEB@microsoft.com...
> > Thanks Simon,
> > Indeed in Wordpad the leading zeroes are there. That is what I said to the
> > users but they don't accept that: they want to see them in Excel. So I'm
> > trying to find a way to do it anyway.
> > Solutions like placing [] or {} around it they don't accept neither...
> > --
> >
> >
> >
> > "Simon Whale" wrote:
> >
> >> Hi Optimo,
> >>
> >> how are you opening that CSV file? are you opening it in excel, if so
> >> you
> >> will lose the leading zero. have a look at the file in notepad or
> >> wordpad
> >>
> >> Simon
> >>
> >> "Optimo" <Optimo@discussions.microsoft.com> wrote in message
> >> news:35D08E3B-2F3D-423F-A863-98570DAA4A1E@microsoft.com...
> >> > In a procedure I export the contence of a datagrid to a CSV file. No
> >> > problems
> >> > there. Only two of the columns contain numbers with leading zeroes.
> >> > Those
> >> > leading zeroes disapear in the CSV file, but they must be retained.
> >> > I tried to add a single quote (as one could do in an Excel worksheet to
> >> > save
> >> > a number as text), but that doesn't work.
> >> > Adding a space in front doesn't change a thing and I cannot add any
> >> > readable
> >> > character that is not part of the original number.
> >> > So how can I retain the leading zeroes during export to a CSV file?
> >> > The datatype of those two columns in the grid is nvarchar (string).
> >> >
> >> > Thanks
> >>
> >>
> >>
>
>
How do they feel about macros? Assuming your numbers are in columns A and B,
the following macro will put the leading zeros back in:
Sub Macro1()
Columns("A:B").Select
Selection.NumberFormat = "00000"
End Sub
It's not exactly rocket science, but it could solve your problem without the
users needing to do much work (and you could always code it in an Auto_open
macro if they won't run it for you).
HTH
Steve
[quoted text, click to view] "Optimo" <Optimo@discussions.microsoft.com> wrote in message
news:0A7758F8-7966-4A72-A907-DDF1FB9B83CB@microsoft.com...
> Thanks Simon
>
> But that was one of the first things I did: it doesn't work.
> When you open the CSV file in Excel the quote is visible in the cells.
> You have to click every single cell separately, click in the formulebar
> and
> then Enter.
> Users are not prepared to do that, because they sometimes export over
> 10000
> lines.
> Of course they also could make use of Excel functions like =TEXT(), but
> that
> is no option for them.
> I even tryed to export that Excel-function but there the parameter
> separators mess everything up.
> --
> ICT
>
>
> "Simon Whale" wrote:
>
>> if you want to use CSV files, try putting a single quote before the
>> number.
>>
>> e.g. '01234567
>>
>> Hope it Helps
>> Simon
>>
>> "Optimo" <Optimo@discussions.microsoft.com> wrote in message
>> news:9583B3D9-D680-42E9-BC3E-213C80EE8AEB@microsoft.com...
>> > Thanks Simon,
>> > Indeed in Wordpad the leading zeroes are there. That is what I said to
>> > the
>> > users but they don't accept that: they want to see them in Excel. So
>> > I'm
>> > trying to find a way to do it anyway.
>> > Solutions like placing [] or {} around it they don't accept neither...
>> > --
>> >
>> >
>> >
>> > "Simon Whale" wrote:
>> >
>> >> Hi Optimo,
>> >>
>> >> how are you opening that CSV file? are you opening it in excel, if so
>> >> you
>> >> will lose the leading zero. have a look at the file in notepad or
>> >> wordpad
>> >>
>> >> Simon
>> >>
>> >> "Optimo" <Optimo@discussions.microsoft.com> wrote in message
>> >> news:35D08E3B-2F3D-423F-A863-98570DAA4A1E@microsoft.com...
>> >> > In a procedure I export the contence of a datagrid to a CSV file. No
>> >> > problems
>> >> > there. Only two of the columns contain numbers with leading zeroes.
>> >> > Those
>> >> > leading zeroes disapear in the CSV file, but they must be retained.
>> >> > I tried to add a single quote (as one could do in an Excel worksheet
>> >> > to
>> >> > save
>> >> > a number as text), but that doesn't work.
>> >> > Adding a space in front doesn't change a thing and I cannot add any
>> >> > readable
>> >> > character that is not part of the original number.
>> >> > So how can I retain the leading zeroes during export to a CSV file?
>> >> > The datatype of those two columns in the grid is nvarchar (string).
>> >> >
>> >> > Thanks
>> >>
>> >>
>> >>
>>
>>
>>