DIVINEDAR0956
IS-IT--Management
Could someone please help me.
I have an excel file that I want to transfer into access. This has worked in the pass and now all of a sudden I am getting this error message EXTERNAL TABLE IS NOT IN THE EXPECTED FORMAT . I can't seem to figure out if there is a library I need to download or my excel program isn't saving my excel file properly.
I have the following code:
Public Function updatelink()
'EditProjectNumber
Dim dbsDocument As Database
Dim rstDocument As Recordset
Dim sTable As String
Dim strFileName As String
strFileName = FileDialog
'Search for the temporal file name in access. Delete the table when found
' Add your TransferSpreadsheet code here...
sTable = "Project"
DeleteTable (sTable)
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, sTable, strFileName, True, "PROJECT_EXTRACT"
sTable = "TASK"
DeleteTable (sTable)
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, sTable, strFileName, True, "TASK_EXTRACT"
sTable = "HRSENTER"
DeleteTable (sTable)
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, sTable, strFileName, True, "HOURS_EXTRACT"
sTable = "RATE"
DeleteTable (sTable)
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, sTable, strFileName, True, "RATE_EXTRACT"
sTable = "VENDOR"
DeleteTable (sTable)
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, sTable, strFileName, True, "VENDOR_EXTRACT"
End Function
Each of these tables to be imported is calculated in an excel file. I don't know if my problem could be in this script or in my FileDialog script as follows:
Public Function FileDialog()
'Declare a variable as a FileDialog object.
Dim fd As FileDialog
'Create a FileDialog object as a File Picker dialog box.
Set fd = Application.FileDialog(msoFileDialogFilePicker)
'Declare a variable to contain the path
'of each selected item. Even though the path is a String,
'the variable must be a Variant because For Each...Next
'routines only work with Variants and Objects.
Dim vrtSelectedItem As Variant
'Use a With...End With block to reference the FileDialog object.
With fd
'Add a filter that includes GIF and JPEG images and make it the first item in the list.
.Filters.Add "Excel Spreadsheet", "*.xls", 1
'Use the Show method to display the File Picker dialog box and return the user's action.
'The user pressed the action button.
If .Show = -1 Then
vrtSelectedItem = .SelectedItems(1)
'Step through each string in the FileDialogSelectedItems collection.
'For Each vrtSelectedItem In .SelectedItems
'vrtSelectedItem is a String that contains the path of each selected item.
'You can use any file I/O functions that you want to work with this path.
'This example simply displays the path in a message box.
'MsgBox "The path is: " & vrtSelectedItem
FileDialog = vrtSelectedItem
'Next vrtSelectedItem
'The user pressed Cancel.
Else
FileDialog = Null
End If
End With
'Set the object variable to Nothing.
Set fd = Nothing
End Function
I have open the excel file and saved it several different ways change the acSpreadsheetTypeExcel(8)
My excel spreadsheet that is used to import has the following code that saves the file in a specific directory automatically. Could my error possibly be in the following code:
Sub LockOut()
Dim sFileName As String
'Create a string of the file that you are saving
sFileName = "n:\CostAnalysis\Projects\" & Worksheets("PROJECT_INFORMATION".Range("B2".Value
'Send a message dialog to screen
MsgBox "Saving: " & sFileName
ShowSheets
'Save a write protected copy out to the j:' ActiveWorkbook.SaveCopyAs Filename:= _
' sFileName, WriteResPassword:="deleon", CreateBackup:=False
ActiveWorkbook.SaveAs Filename:=sFileName, FileFormat:= _
xlNormal, Password:="", WriteResPassword:="deleon", ReadOnlyRecommended:= _
False, CreateBackup:=False
HideSheets
End Sub
If anyone has any ideas why this is happening please tell me.
Thank you for your help and your patience.
Darlene Sippio
dsippio@comtechsystems.com
I have an excel file that I want to transfer into access. This has worked in the pass and now all of a sudden I am getting this error message EXTERNAL TABLE IS NOT IN THE EXPECTED FORMAT . I can't seem to figure out if there is a library I need to download or my excel program isn't saving my excel file properly.
I have the following code:
Public Function updatelink()
'EditProjectNumber
Dim dbsDocument As Database
Dim rstDocument As Recordset
Dim sTable As String
Dim strFileName As String
strFileName = FileDialog
'Search for the temporal file name in access. Delete the table when found
' Add your TransferSpreadsheet code here...
sTable = "Project"
DeleteTable (sTable)
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, sTable, strFileName, True, "PROJECT_EXTRACT"
sTable = "TASK"
DeleteTable (sTable)
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, sTable, strFileName, True, "TASK_EXTRACT"
sTable = "HRSENTER"
DeleteTable (sTable)
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, sTable, strFileName, True, "HOURS_EXTRACT"
sTable = "RATE"
DeleteTable (sTable)
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, sTable, strFileName, True, "RATE_EXTRACT"
sTable = "VENDOR"
DeleteTable (sTable)
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, sTable, strFileName, True, "VENDOR_EXTRACT"
End Function
Each of these tables to be imported is calculated in an excel file. I don't know if my problem could be in this script or in my FileDialog script as follows:
Public Function FileDialog()
'Declare a variable as a FileDialog object.
Dim fd As FileDialog
'Create a FileDialog object as a File Picker dialog box.
Set fd = Application.FileDialog(msoFileDialogFilePicker)
'Declare a variable to contain the path
'of each selected item. Even though the path is a String,
'the variable must be a Variant because For Each...Next
'routines only work with Variants and Objects.
Dim vrtSelectedItem As Variant
'Use a With...End With block to reference the FileDialog object.
With fd
'Add a filter that includes GIF and JPEG images and make it the first item in the list.
.Filters.Add "Excel Spreadsheet", "*.xls", 1
'Use the Show method to display the File Picker dialog box and return the user's action.
'The user pressed the action button.
If .Show = -1 Then
vrtSelectedItem = .SelectedItems(1)
'Step through each string in the FileDialogSelectedItems collection.
'For Each vrtSelectedItem In .SelectedItems
'vrtSelectedItem is a String that contains the path of each selected item.
'You can use any file I/O functions that you want to work with this path.
'This example simply displays the path in a message box.
'MsgBox "The path is: " & vrtSelectedItem
FileDialog = vrtSelectedItem
'Next vrtSelectedItem
'The user pressed Cancel.
Else
FileDialog = Null
End If
End With
'Set the object variable to Nothing.
Set fd = Nothing
End Function
I have open the excel file and saved it several different ways change the acSpreadsheetTypeExcel(8)
My excel spreadsheet that is used to import has the following code that saves the file in a specific directory automatically. Could my error possibly be in the following code:
Sub LockOut()
Dim sFileName As String
'Create a string of the file that you are saving
sFileName = "n:\CostAnalysis\Projects\" & Worksheets("PROJECT_INFORMATION".Range("B2".Value
'Send a message dialog to screen
MsgBox "Saving: " & sFileName
ShowSheets
'Save a write protected copy out to the j:' ActiveWorkbook.SaveCopyAs Filename:= _
' sFileName, WriteResPassword:="deleon", CreateBackup:=False
ActiveWorkbook.SaveAs Filename:=sFileName, FileFormat:= _
xlNormal, Password:="", WriteResPassword:="deleon", ReadOnlyRecommended:= _
False, CreateBackup:=False
HideSheets
End Sub
If anyone has any ideas why this is happening please tell me.
Thank you for your help and your patience.
Darlene Sippio
dsippio@comtechsystems.com