使用VBA宏运行批处理文件 [英] to run a batch file using VBA macro

查看:551
本文介绍了使用VBA宏运行批处理文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我创建了一个批处理文件,用于将csv文件从远程服务器复制到我的桌面,当我执行它时工作正常。

我想要使用excel宏调用该批处理文件,如下所示:



Hi,
I have created a batch file to copy a csv file from a remote server to my desktop which works fine when I execute it.
I want to invoke that batchfile using excel macro which is as follows:

Sub ftp_file()
Dim getfile As Double
getfile = Shell("c:\folder\needtorun.bat", vbNormalFocus)
End Sub

它不会将所需文件复制到目标。我已经重新检查了我的批处理文件,并且在独立运行时没有问题。

其中一种可能是,exel宏不会等到ftp完成。如何确定问题发生的步骤?我该怎么办呢?



有没有人之前处理过类似的问题?任何帮助表示赞赏。



提前致谢!

It does not copy the required file to the destination. I have re checked my batchfile and it has no issues when run independently.
One of the possibility could be, exel macro does not wait until the ftp is complete. How can I check at which step the problem is occuring? How can I go about it?

Has anybody tackled the similar issue before? Any help is appreciated.

Thanks in advance!

推荐答案

而不是使用批处理,请使用 FileCopy [ ^ ]方法。
Instead using batch, use FileCopy[^] method.


这篇关于使用VBA宏运行批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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