is there an equivalent code for
in excel vba?
this is the code im trying to currently use in excel VBA:
Code:
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, _
this is the code im trying to currently use in excel VBA:
Code:
Private Sub CommandButton2_Click()
Dim fDialog As FileDialog
Dim varFile As Variant
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
.AllowMultiSelect = False
.Filters.Add "Excel File", "*.xls"
.Filters.Add "Excel File", "*.xlsx"
If .Show = True Then
For Each varFile In .SelectedItems
Const acImport = 0
Const acSpreadsheetTypeExcel9 = 8
GetSheets varFile
Next
MsgBox ("import")
End If
End With
End Sub
Sub GetSheets(strFileName)
Dim objXL As New Excel.Application
Dim wkb As Excel.Workbook
Dim wks As Object
Dim blnHasFieldNames As Boolean
'objXL.Visible = True
blnHasFieldNames = True
Set wkb = objXL.Workbooks.Open(strFileName)
For Each wks In wkb.Worksheets
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, _
blnHasFieldNames, wks.Name, strFileName, True, wks.Name & "$"
Next
wkb.Close
Set wkb = Nothing
objXL.Quit
Set objXL = Nothing
End Sub