运行一个Excel宏-BAtch File Ugliness! [英] Run an Excel Macro - BAtch File Ugliness!

查看:142
本文介绍了运行一个Excel宏-BAtch File Ugliness!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在excel中,我会定期运行宏.
我将以下行作为宏的一部分来运行批处理文件:

Within excel I run a macro at regular intervals.
I use the following line as part of the macro to run a batch file:

Call Shell(Environ$("COMSPEC") & " /c C:\Temp\autoftp.bat", vbNormalFocus)




所有这些操作就是打开ftp连接,调用.dat文件以填充所需的信息,然后上传并关闭.

有什么方法可以运行批处理文件,而不会在屏幕上弹出DOS Shell来运行该文件?

它只有一秒钟左右的时间,但是很烦人并且分散注意力.




All this does is open an ftp connection, call the .dat file to populate the required information, upload and close.

Is there any way of running the batch file without the DOS Shell popping up on the screen to run the file?

It is only there for a second or so but it is annoying and distracting.

推荐答案

(" COMSPEC")& " ,vbNormalFocus)
("COMSPEC") & " /c C:\Temp\autoftp.bat", vbNormalFocus)




所有这些操作就是打开ftp连接,调用.dat文件以填充所需的信息,然后上传并关闭.

有什么方法可以运行批处理文件,而不会在屏幕上弹出DOS Shell来运行该文件?

它只有一秒钟左右的时间,但是很烦人并且分散注意力.




All this does is open an ftp connection, call the .dat file to populate the required information, upload and close.

Is there any way of running the batch file without the DOS Shell popping up on the screen to run the file?

It is only there for a second or so but it is annoying and distracting.


使用vbHide而不是vbNormalFocus
因此,请尝试以下一个
Use vbHide instead of vbNormalFocus
So try the below one
Call Shell(Environ


(" COMSPEC")& /c C :\ Temp \ autoftp.bat" ,vbHide)
("COMSPEC") & " /c C:\Temp\autoftp.bat", vbHide)


仅供参考
Visual Basic for Applications参考-Shell函数 [ ^ ]


FYI
Visual Basic for Applications Reference - Shell function[^]


这篇关于运行一个Excel宏-BAtch File Ugliness!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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