Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to change the data type in excel spreadsheet from Access vba?

Status
Not open for further replies.

sabavno

Programmer
Jul 25, 2002
381
CA
Hi,

I want to do the following:

Before I import the excel spreadsheet into Access table, I want to be able to access that spreadsheet and change the data type of some columns in it. Since I don't want my user do it manually, I am looking for the VBA code to solve this problem.

Please advise.

Thanks.
 
This example open an excel file (C:\Test\Test.xls) and changes the format of column B to dd/mmm/yyyy, closes and saves the file.

Private Sub mChangeExcelFormat()

Dim ExcelApp As New Excel.Application
With ExcelApp

.Workbooks.Open "c:\test\test.xls"
.Visible = True
.Columns("B").NumberFormat = "dd/mmm/yyyy"
.ActiveWorkbook.Close True
.Quit

End With

Set ExcelApp = Nothing

End Sub

Hopefully this will provide a good starting point for what you need to do.

You will need a reference to Microsoft Excel object library

There are two ways to write error-free programs; only the third one works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top