欢迎来到天天文库
浏览记录
ID:16369670
大小:48.64 KB
页数:4页
时间:2018-08-09
《ms office 2010中软件宏的编写》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、参考《计算机语言综合实训》(电子工业出版社)实践MSOffice2010中软件宏的编写1、MSOfficeWord要了解Word宏的写法,先从录制宏、然后查看其代码(1)打开Word2010,点击菜单栏的”视图”——>”宏”——>”录制新宏”,接下来就是平常的操作喽,相信一看就会。单击“确定”按钮,进入宏录制状态。(2)开始宏的录制你接下来的操作都是作为宏在录制。比如,这里我们建个3行5列的表格,在表格标题行里输入”学号”、”姓名”、”性别”、”出生日期”、”班级 ”(3)结束宏的录制再次点击”宏”——>”停止录制”菜单,完成宏的录制工作。(4)查看宏代码点击”
2、宏”——>”查看”——>”编辑”即可看到我们刚才所录制的宏,如下:SubCreateTable()''CreateTable宏'插入一个特殊表格'ActiveDocument.Tables.AddRange:=Selection.Range,NumRows:=3,NumColumns:=_5,DefaultTableBehavior:=wdWord9TableBehavior,AutoFitBehavior:=_wdAutoFitFixedWithSelection.Tables(1)If.Style<>"网格型"Then.Style="网格型"EndIf.Ap
3、plyStyleHeadingRows=True.ApplyStyleLastRow=False.ApplyStyleFirstColumn=True.ApplyStyleLastColumn=False.ApplyStyleRowBands=True.ApplyStyleColumnBands=FalseEndWithWithOptions.DefaultBorderLineStyle=wdLineStyleDouble.DefaultBorderLineWidth=wdLineWidth050pt.DefaultBorderColor=wdColorAuto
4、maticEndWithSelection.TypeTextText:="学号"Selection.MoveRightUnit:=wdCellSelection.TypeTextText:="姓名"Selection.MoveRightUnit:=wdCellSelection.TypeTextText:="出生日期"Selection.MoveRightUnit:=wdCellSelection.TypeBackspaceSelection.MoveLeftUnit:=wdCharacter,Count:=1Selection.TypeBackspaceSel
5、ection.TypeBackspaceSelection.TypeBackspaceSelection.TypeBackspaceSelection.TypeTextText:="性别"Selection.MoveRightUnit:=wdCellSelection.TypeTextText:="出生日期"Selection.MoveRightUnit:=wdCellSelection.TypeTextText:="班级"Selection.ParagraphFormat.Alignment=wdAlignParagraphCenterSelection.Mo
6、veLeftUnit:=wdCharacter,Count:=3Selection.ParagraphFormat.Alignment=wdAlignParagraphCenterSelection.MoveLeftUnit:=wdCharacter,Count:=6Selection.MoveRightUnit:=wdCharacter,Count:=1Selection.ParagraphFormat.Alignment=wdAlignParagraphCenterSelection.MoveLeftUnit:=wdCharacter,Count:=3Sel
7、ection.ParagraphFormat.Alignment=wdAlignParagraphCenterSelection.MoveLeftUnit:=wdCharacter,Count:=3Selection.ParagraphFormat.Alignment=wdAlignParagraphCenterEndSub通过阅读代码,我们也可知道代码中的一些关键字的含义。例如:ActiveDocument代表当前Word文档对象,Tables代表所有表格对象的集合,Tables(1)指的是文档中第1个表格的对象,Rows代表表格行对象集合,Coloumns代
8、表表格列对象集合,Cel
此文档下载收益归作者所有