博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
VBA代码收集
阅读量:4298 次
发布时间:2019-05-27

本文共 1479 字,大约阅读时间需要 4 分钟。

//可以通过Word 录制宏,来查看自己需要的代码。

//启动WORD

Set word=CreateObject("Word.Application")
//显示WORD程序界面
word.Visible=True 
//增加一个新文档
word.Documents.Add
//输入文本
word.Selection.TypeText("Hello")
//输入回车
word.Selection.TypeParagraph 
word.Selection.TypeText("good morning")
//保存
word.ActiveDocument.SaveAs("c:\Hello.doc") 
//退出WORD程序
word.Quit(False)
//释放WORD接口

Set word=Nothing 

//

MFC 程序中调用 vbs 脚本文件

SHELLEXECUTEINFO shei;
shei.cbSize = sizeof(shei);
shei.fMask = SEE_MASK_INVOKEIDLIST;
shei.lpFile = _T("001.vbs");
shei.lpVerb = _T("open");
ShellExecute(NULL,shei.lpVerb, shei.lpFile, _T(""), _T(""), SW_SHOW);
system(_T("WScript.exe your.vbs"));

///

Set Word = CreateObject("Word.Application")

Word.Documents.Add
Word.Selection.MoveDown 5, 1000
Word.Selection="统计结果"
Word.Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Word.Selection.Style = Word.ActiveDocument.Styles("标题 1")
Word.Selection.MoveDown 5, 1000
Word.Selection.TypeParagraph
Word.Selection.MoveDown 5, 1000
Word.Selection="统计子项详细信息"
Word.Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
Word.Selection.Style = Word.ActiveDocument.Styles("标题 2")
Word.Selection.MoveDown 5, 1000
Word.Selection.TypeParagraph
Word.Selection.Paste
Word.Selection.MoveDown 5, 1000
Word.Selection.TypeParagraph
Word.ActiveDocument.SaveAs ("d:\test.doc")
Word.Quit (False)
Set Word = Nothing

///

.PageWidth = CentimetersToPoints(21)

.PageHeight = CentimetersToPoints(29.7)
 

///参考文章

http://www.vckbase.com/index.php/wv/797  让你的程序也能执行脚本 

转载地址:http://clnws.baihongyu.com/

你可能感兴趣的文章
理解RESTful架构
查看>>
我的第1台Iphone与MacBook
查看>>
论PHP面向对象之-多态
查看>>
设计模式系列·初探设计模式之王小二的疑问
查看>>
创新模式 ---三级火箭:深度讲解互联网降维打击
查看>>
python 的常用时间操作
查看>>
python 的日志logging模块
查看>>
python StringIo,Base64,上传文件
查看>>
python urllib2, urllib使用
查看>>
python 调用短信接口
查看>>
MySQL:按前缀批量删除表格
查看>>
SQLALchemy-查询篇
查看>>
SQLAlchemy基础篇(连接mysql数据库)
查看>>
SQLAlchemy进阶篇
查看>>
MVC框架介绍
查看>>
python+django MTV框架 和php MVC框架的不同之处
查看>>
mysql基本+深入操作集
查看>>
git详细介绍
查看>>
Python contextlib——上下文管理器
查看>>
vim基本命令
查看>>