View Full Version : HELP! Excel changes field properties


kuipers78
08-26-2008, 05:49 AM
Hello,

I'm trying to export data to an Excel spreadsheet (using VBA), which usually works fine. But now I have the following problem:
When I try to export a date, Excel defines it's own field property and mask to it. And this means a date notation I don't wanna use!
So, I've tried to convert the date to a string or give it a certain date format (using VBA, works fine in Access), but when I export it to Excel the format keeps changing :(
How can I avoid this by letting Excel know that the date has to be treated as plain text (in the field properties)????

Here is my code:



Dim ExDate as String

Set ExcelSheet = CreateObject("Excel.Sheet")
ExcelSheet.Application.Visible = True

ExDate = Format(now, "dd\-mm\-yyyy")

ExcelSheet.ActiveSheet.cells(1, 1).Value = ExDate



Also tried (didn't work either):



ExcelSheet.ActiveSheet.cells(1, 1).Value = Format(ExDate, "dd\-mm\-yyyy")



Any help will be greatly appreciated!

Alisa
08-26-2008, 10:48 AM
Haven't worked with excel in quite awhile now, but doesn't putting ' in front of something make excel see it as text?

Brianwarnock
08-26-2008, 10:56 AM
I think that you have to use TEXT(value,Format...)

Brian