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

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

 

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:
确定

拖动滑块以完成验证