Hallo Omar,
das kann man aber auch aus Access direkt machen, wenn man wie in meinem Fall keinen Einfluss auf die EXCEL-Sheets hat, die von iregndwo anders herkommen. Hier ein Auszug aus meiner Routine:
Public Function FormatEXCELCellToText()
On Error GoTo HandleErr
Dim ExcelApp As Object
Dim NewMap As Object
Dim xlsRange As Object
Dim wrkBook As Object
Dim lLastRow As Long
Dim lastCellName As String
’ Create instance of EXCEL-Obj
Set ExcelApp = CreateObject(„excel.application“)
ExcelApp.Visible = False
’ Load Worksheet in XLS-File, here I know the name of the worksheet
Set NewMap = ExcelApp.Workbooks.Open(„XLSFileName“)
ExcelApp.Worksheets(„WorksheetName“).Activate
'Determine last row
lLastRow = ExcelApp.ActiveSheet.Cells.SpecialCells(11).Row
’ Select one complete row and set format to text… works with other formats also
Set xlsRange = ExcelApp.Range(„A3:A“ & lLastRow)
xlsRange.Select
xlsRange.Activate
xlsRange.NumberFormat = „@“
’ Next row
Set xlsRange = ExcelApp.Range(„B3:B“ & lLastRow)
xlsRange.Select
xlsRange.Activate
xlsRange.NumberFormat = „@“
’ =========================================
’ Und so weiter fuer jede gewuenschte Spalte
’ =========================================
’ Close the workbook and the EXCEL-Instance
For Each wrkBook In ExcelApp.Workbooks
wrkBook.Close (True)
Next wrkBook
ExcelApp.Quit
Set ExcelApp = Nothing
DoEvents
ExitHere:
Exit Function
HandleErr:
Select Case Err.Number
Case Else
MsgBox "Error " & Err.Number & ": " & Err.Description, vbCritical, „General.FormatEXCELCellToText“
End Select
Resume ExitHere
Resume Next
End Function
Tschau and hope this helps
Peter
[Bei dieser Antwort wurde das Vollzitat nachträglich automatisiert entfernt]