用word制宏作红头文件格式.docVIP

  • 106
  • 0
  • 约4.24千字
  • 约 8页
  • 2017-04-10 发布于四川
  • 举报
用word制宏作红头文件格式

用word宏制作红头文件格式 2010-09-29 20:53 现在把代码贴出来,以后进行说明 Sub redup() 一键设置红头文件格式 一、定义变量 ?? Dim am, nam, row, nrow As Integer ?? Dim bt As String ?? Dim fso As New FileSystemObject ========================================================================================================================== ??? 二、获得标题信息 ??? Selection.HomeKey Unit:=wdStory ??? WordBasic.SelectSimilarFormatting ??? bt = Selection ============================================================================================================================ ??? 三、获得文件编号 ??? Set 自动 = fso.OpenTextFile(D:\dcf 日记\发文\autonum.txt) ??? am = 自动.ReadLine ??? 自动.Close ??? 四、获得编号后,编号按顺序+1,以共下次使用 ???? nam = am + 1 ???? Open D:\dcf 日记\发文\autonum.txt For Output As #1 output是输出到txt中 ???? Print #1, Str(nam) ???? Close #1 ============================================================================================================================ ??? 获得本文档的名字,以便以后激活文档用 ???? myname = ActiveDocument.Name ============================================================================================================================= ??? ??? 五、读取登记本中的列数 ??? Set 登记表 = fso.OpenTextFile(D:\dcf 日记\发文\登记本的列数.txt) ??? row = 登记表.ReadLine ??? 登记表.Close ============================================================================================================================= ??? 六、打开并激活登记本 ??? ChangeFileOpenDirectory D:\dcf 日记\发文\ ??? Documents.Open FileName:=发文登记表.doc ??? Windows(发文登记表.doc).Activate =============================================================================================================================== ??? 七、填写内容 ??? ActiveDocument.Tables(1).Cell(row, 6).Range.Text = bt ??? ActiveDocument.Tables(1).Cell(row, 6).Range.Text = bt ??? ActiveDocument.Tables(1).Cell(row, 2).Range.Text = Str(am) ??? ActiveDocument.Tables(1).Cell(row, 1).Range.Text = Str(am) ??? ActiveDocument.Tables(1).Cell(row, 5).Range.Text = 市政府 ??? ActiveDocument.Tables(1).Cell(row, 7).Range.Text = 6 ??? ActiveDocument.Tables(1).Cell(row, 8).Range.

文档评论(0)

1亿VIP精品文档

相关文档