Log in

View Full Version : How change cell format in excel using VBA in MS access



Ronald_yoh
03-09-2009, 10:39 PM
Hi there,

i'm trying to change cell format in excel as "text" from MS Access (VBA).

how do i achive this?

i tried the following code in MS Access but no luck (does not change the format):


Set oExcelApp = New Excel.Application
oExcelApp.Workbooks.Open ("C:\book1.xls")
oExcelApp.Visible = True
oExcelApp.Sheets(1).Activate
oExcelApp.Sheets(1).Cells.Select

With oExcelApp.ActiveCell
.NumberFormat = "@"
End With

oExcelApp.ActiveWorkbook.Save
oExcelApp.Quit


thanks
R

OBP
03-10-2009, 08:07 AM
Are you trying to change it FROM Text?
Or TO text?

CreganTur
03-10-2009, 11:03 AM
Depending on what yuo're doing, you might have to change the formatting on your spreadsheet and then re-enter your data to get it to correctly conform to the format you've declared.

Ronald_yoh
03-10-2009, 02:59 PM
Hi all,

thanks for replying..

anyway, i've solved the issue!

thanks again!