I am trying to import an Excel spreadsheet into Access 2013 using a macro. Is there a way to make the macro prompt for a file path instead of having a static file path? I would like to have a message box or something similar be provided to the user to define the file path for each Excel file they would like to import. Is there a macro for this?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You could use a InputBox via vba
Dim p As String
p = InputBox("please input file path")
Debug.Print p
I am not sure however how to achieve the same thing with just a macro.
回答2:
Use this function:
Function seleccionarArchivo()
Set f = Application.FileDialog(3)
f.AllowMultiSelect = False
f.Filters.Clear
f.Filters.Add "Todos", "*.*"
If f.Show Then
seleccionarArchivo = f.SelectedItems.Item(1)
End If
Set f = Nothing
End Function
To try, put a button and add this in the click event:
MsgBox (seleccionarArchivo)