Hi
I have a module that I have created that imports data from a spreadsheet into a table through a subroutine and that works fine.
I am now trying to run that subroutine using a macro but do not seem to be successful.
I have tried "OpenModule" but that just opens the VBA code, does not run it
I have tried "RunMacro" but the subroutine is not shown
I have tried "RunCode" but that is looking for a function, but not sure I have that. I am still a novice at this game.
The code I have at the moment is as follows:
Code:
Sub TestImport()
Dim strPathFile As String
Dim strTable As String, strBrowseMsg As String
Dim strFilter As String, strInitialDirectory As String
Dim blnHasFieldNames As Boolean
blnHasFieldNames = True
strBrowseMsg = "Select the EXCEL file:"
strInitialDirectory = "C:\Documents and Settings\"
strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.xlsx)", "*.xlsx")
strPathFile = ahtCommonFileOpenSave(InitialDir:=strInitialDirectory, _
Filter:=strFilter, OpenFile:=False, _
DialogTitle:=strBrowseMsg, _
Flags:=ahtOFN_HIDEREADONLY)
If strPathFile = "" Then
MsgBox "No file was selected.", vbOK, "No Selection"
Exit Sub
End If
strTable = "Test"
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, _
strTable, strPathFile, blnHasFieldNames
Kill strPathFile
End Sub
Any help would be very gratefully received
Thanks