Excel VBA中,Appactivate, Shell, Open, Print,等语句的使用方法

网站编辑
网站编辑
编辑
1211
文章
0
粉丝
互联网&数码 技术流1 18,8563阅读模式

Open 和Print组合,可实现向文本文件中写入数据:

如文章源自原紫番博客-https://www.yuanzifan.com/4288.html

Open "D:/Yuanzifan.txt" for output as #1  ‘以写入方式打开文本文件,并把这个文件设置编号 “#1”文章源自原紫番博客-https://www.yuanzifan.com/4288.html

Print #1,"Yuanzifan.com"  '向文件中写入 字符串Yuanzifan.com文章源自原紫番博客-https://www.yuanzifan.com/4288.html

Close #1   '关闭文件,需要注意的是每个文件打开后必须关闭,否则下次再使用的时候会提示文件已打开。文章源自原紫番博客-https://www.yuanzifan.com/4288.html

+++++++++++文章源自原紫番博客-https://www.yuanzifan.com/4288.html

Appactivate :文章源自原紫番博客-https://www.yuanzifan.com/4288.html

此方法的作用是,无论目标程序是否最大化,都让目标程序获得焦点,即让系统可以操作目标程序;文章源自原紫番博客-https://www.yuanzifan.com/4288.html

Shell:文章源自原紫番博客-https://www.yuanzifan.com/4288.html

aa=Shell ("CALC.EXE",vbNormalFourc)  '打开计算器,并使其获得焦点,次函数的返回值是一个double的数字,该数字记录的是进程ID.文章源自原紫番博客-https://www.yuanzifan.com/4288.html 文章源自原紫番博客-https://www.yuanzifan.com/4288.html

站长微信
扫码添加(注明来意)
weinxin
Yuanzifan99
微信号已复制
原梓番博客公众号
博客内容精选
weinxin
原梓番博客
公众号已复制
 

发表评论

匿名网友
确定

拖动滑块以完成验证