G
Guest
Hi,
I have seen the articles referencing
http://www.mvps.org/access/api/api0001.htm to call a dialog box, but I can't
seem to get it to work. It always asks me for a macro. At first I was using
the code below from a database I inherited, but it doesn't seem to work in
Access 2002/2003 file formats. That's when I found articles referencing the
API example. I think I just don't understand enough about VBA programming,
so any pointers would be helpful.
Thanks.
-------------
Function ImportMatrix()
Dim sFilename As Office.FileDialog
DoCmd.RunMacro "mcrDeleteMatrix"
DoCmd.SetWarnings (WarningsOn)
Set dlgOpen = Application.FileDialog(dialogtype:=msoFileDialogOpen)
With dlgOpen
.AllowMultiSelect = False
.Show
End With
If dlgOpen.SelectedItems.Count = 0 Then Exit Function
sPath = dlgOpen.SelectedItems.Item(1)
On Error GoTo ImportMatrix_Err
DoCmd.SetWarnings False
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9,
"tblMatrix", sPath, True
DoCmd.SetWarnings True
MsgBox "Import Complete"
ImportMatrix_Exit:
Exit Function
ImportMatrix_Err:
MsgBox Error$
Resume ImportMatrix_Exit
End Function
I have seen the articles referencing
http://www.mvps.org/access/api/api0001.htm to call a dialog box, but I can't
seem to get it to work. It always asks me for a macro. At first I was using
the code below from a database I inherited, but it doesn't seem to work in
Access 2002/2003 file formats. That's when I found articles referencing the
API example. I think I just don't understand enough about VBA programming,
so any pointers would be helpful.
Thanks.
-------------
Function ImportMatrix()
Dim sFilename As Office.FileDialog
DoCmd.RunMacro "mcrDeleteMatrix"
DoCmd.SetWarnings (WarningsOn)
Set dlgOpen = Application.FileDialog(dialogtype:=msoFileDialogOpen)
With dlgOpen
.AllowMultiSelect = False
.Show
End With
If dlgOpen.SelectedItems.Count = 0 Then Exit Function
sPath = dlgOpen.SelectedItems.Item(1)
On Error GoTo ImportMatrix_Err
DoCmd.SetWarnings False
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9,
"tblMatrix", sPath, True
DoCmd.SetWarnings True
MsgBox "Import Complete"
ImportMatrix_Exit:
Exit Function
ImportMatrix_Err:
MsgBox Error$
Resume ImportMatrix_Exit
End Function