Access中的宏,用于在导入文件时提示输入文件路径 [英] Macro in Access to prompt for file path when importing file

查看:206
本文介绍了Access中的宏,用于在导入文件时提示输入文件路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用宏将Excel电子表格导入Access 2013.有没有一种方法可以使宏提示输入文件路径,而不是使用静态文件路径?我希望有一个消息框或类似的内容提供给用户,以便为他们要导入的每个Excel文件定义文件路径.有一个宏吗?

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?

推荐答案

使用此功能:

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

要尝试,请放置一个按钮并将其添加到click事件中:

To try, put a button and add this in the click event:

      MsgBox (seleccionarArchivo)

这篇关于Access中的宏,用于在导入文件时提示输入文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆