用于更改Excel文件名的VBA脚本 [英] VBA Script to Change an Excel Filename

查看:67
本文介绍了用于更改Excel文件名的VBA脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Access数据库我正在从Excel文件导入记录。我目前通过创建Excel表格的链接表来进行设置。但我不确定这是做我想要达到的目标的最好方法。所以,我有两个问题:


1)用户将所有Excel文件复制到一个文件夹中(这正是我目前设想的方式)。有没有办法从文件夹中的所有这些文件中复制记录,而不必将它们的用户名完全相同。

例如:如果有一个名为Test.xls的文件,和Test2.xls和Test2.xls。我可以把这些文件的记录添加到表中吗?


2)我可以重命名已经导入的文件吗我可以检查这样我就知道哪些文件已被处理过了。如果我不能完成我在#1中描述的任务,那么我可以一次完成一个文件。 这是两者中更重要的

例如:一旦他导入了Test.xls, - 我可以将其更改为Test - Imported.xls


提前感谢您提供任何帮助

解决方案

订阅。


您可以使用以下代码,但在导入文件后将文件移动到新文件夹而不是重命名。此代码设置在名为cmdImportExcelFiles的命令按钮后面。

展开 | 选择 | Wrap | 行号


非常感谢 - 像魅力一样工作!!!

I have an Access database I am importing records into from an Excel file. I currently have set it up by creating a linked table to the Excel sheet. But I am not sure that is the best way to do what I''m trying to achieve. So, I have two questions:


1) The user will be copying all the Excel files into one folder (this is just how I currently envision it). Is there a way to copy records from all those files in the folder, without having to have the user name them all the same.

For example: If there is a file named "Test.xls" and "Test2.xls" can I get it to add both those files'' records to the table?

2) Can I rename the files that have been imported do that I can mae a check so that I know which files hvae been already processed. If I can''t do the task i described in #1, then I could do this one one file at a time. This is the more important of the two

For example: Once he has imported "Test.xls" - can I change it to "Test - Imported.xls"

Thanks in advance for any help

解决方案

Subscribing.


You can use the following code but move the files to a new folder after they are imported rather than renaming them. This code is set behind a command button called cmdImportExcelFiles.

Expand|Select|Wrap|Line Numbers


Thanks so much - worked like a charm!!!


这篇关于用于更改Excel文件名的VBA脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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