将Access查询导出到xls后如何使用VB自动重命名文件? [英] After exporting Access query to xls how do I use VB to auto-rename the file?

查看:175
本文介绍了将Access查询导出到xls后如何使用VB自动重命名文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的第一个VBA项目差不多完成,看起来很不错,让人印象深刻。但是,我有一个小问题,我确信可以轻松清理。最后我有一个打开查询的按钮,然后立即在excel中打开它(非常类似于excel中的?analyze?预设按钮)。


但是,我的问题是当excel的''export''发生时,文件会自动获取查询的名称,例如 qryMakeFSPAttainmentImportTable。但是,在完成更新excel电子表格中的数据后,需要以FSP Attainment Import的名称将其导入。我意识到我可以告诉别人重命名这个文件,但是你知道,我知道这种情况永远不会是这样的,我会不断发送电子邮件,因为导入函数不起作用。我知道我使用的代码不是最好的,因为当按下按钮时查询被打开并且之后保持打开状态;这也有点痛苦。我已粘贴下面的代码

Nearly finished with my first VBA project and its looking quite good and people seem impressed. However, I have one little problem that I am sure could easily be cleaned up. At the min I have a button that opens a query and then instantly opens it in excel (very similar to the ?analyse in excel? pre-set button).

However, my problem is when the ''export'' to excel takes place the file automatically takes the name of the query e.g. ''qryMakeFSPAttainmentImportTable''. However, after they have finished updating the data in the excel spreadsheet it needs to be imported back in under the name ''FSP Attainment Import''. I realise I could just tell people to rename the file, but you know and I know this would never be the case and I would get constant email''s flying my way saying the import function doesn?t work. I know the code I have used isn?t the best as the query is opened when the button is pressed and stays open afterwards; this is a bit of a pain too. I have pasted my code below

展开 | 选择 | Wrap | 行号

推荐答案

从VBA重命名文件名称声明。
To rename a file from VBA use the Name statement.


关闭您的查询:

to close your query:

展开 | 选择 | Wrap | 行号


谢谢大家好好放手一下让你知道!
thanks guys will give it a go and let you know!


这篇关于将Access查询导出到xls后如何使用VB自动重命名文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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