本文共 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://clnws.baihongyu.com/