Dim docnormal As Document
Private Sub Chk联合发文_Click()
If Txt成文机关 = "—无—" Or Txt联合单位 = "—无—" Then
Chk联合发文 = False
End If
End Sub
Private Sub Chk签发人_Change()
If Txt签发人 = "—无—" Then
Chk签发人 = False
End If
End Sub
Private Sub CmdEND_Click()
ActiveDocument.Close wdDonoSaveChanges
Unload Me
End Sub
Private Sub Cmd选择_Click()
Dim a As Dialog
On Error GoTo e:
Set a = Dialogs(wdDialogCopyFile)
a.directory = Txt保存位置
a.Display
Txt保存位置 = Mid(a.directory, 2, Len(a.directory) - 2)
Exit Sub
e:
a.directory = Options.DefaultFilePath(wdDocumentsPath)
Resume Next
End Sub
Private Sub CmdOK_Click()
Dim i As Integer, widthpage
docnormal.Variables("文件编号") = Txt文件编号 '更改预先定义在模板中变量的值
docnormal.Variables("签发人") = Txt签发人
docnormal.Variables("代字") = Txt代字
docnormal.Variables("年度") = Txt年度
docnormal.Variables("成文机关") = Txt成文机关
docnormal.Variables("联合单位") = Txt联合单位
docnormal.Variables("保存位置") = Txt保存位置
Documents(docnormal).SaveAs , AddToRecentFiles:=False '防止显示在最近文档列表中
Documents(docnormal).Close
Options.PrintDrawingObjects = False
Selection.TypeText Txt年度
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.TypeText Txt文件编号
If Chk签发人 = True Then
Selection.EndKey Unit:=wdLine
With Selection.Font
.Name = "仿宋_GB2312"
.Size = 16
.Bold = True
Selection.TypeText "签发人"
.Name = "楷体_GB2312"
Selection.TypeText ":" + Txt签发人
End With
End If
Selection.MoveDown Unit:=wdLine, Count:=3
Selection.ParagraphFormat.FirstLineIndent = 0
With Selection.Font
.Name = "方正小标宋简体"
.Size = 19
.DisableCharacterSpaceGrid = True
End With
With ActiveDocument.PageSetup
widthpage = .PageWidth - .LeftMargin - .RightMargin
End With
If Chk联合发文 = True Then
With ActiveDocument.PageSetup
widthpage = .PageWidth - .LeftMargin - .RightMargin
End With
If Len(Txt联合单位) < Len(Txt成文机关) Then
Selection.ParagraphFormat.LeftIndent = (widthpage - Len(Txt成文机关) * Selection.Font.Size - 5) / 2
Else
Selection.ParagraphFormat.LeftIndent = (widthpage - Len(Txt联合单位) * Selection.Font.Size - 5) / 2
End If
Selection.ParagraphFormat.RightIndent = Selection.ParagraphFormat.LeftIndent
Selection.ParagraphFormat.Alignment = wdAlignParagraphDistribute
Selection.TypeText Text:=Txt成文机关 + Chr(11) + Txt联合单位
Else
Selection.TypeText Text:=Txt成文机关
End If
Selection.MoveDown Unit:=wdLine, Count:=1
If Chk保存 = True Then
ActiveDocument.SaveAs Txt保存位置 + Txt文件名 + ".doc"
End If
For i = 1 To CommandBars("formatting").Controls.Count '格式工具栏
CommandBars("formatting").Controls(i).Enabled = True '按钮有效
Next i
For i = 3 To CommandBars("Standard").Controls.Count '常用工具栏
CommandBars("Standard").Controls(i).Enabled = True '按钮无效
Next i
Unload Me
End Sub
Private Sub Txt代字_AfterUpdate()
If Txt代字 = "" Then Txt代字 = "公文"
Txt代字 = Trim(Txt代字)
End Sub
Private Sub Txt联合单位_AfterUpdate()
If Txt联合单位 = "" And Txt联合单位 <> "—无—" Then
Txt联合单位 = "—无—"
Chk联合发文 = False
End If
Txt联合单位 = Trim(Txt联合单位)
End Sub
Private Sub Txt成文机关_AfterUpdate()
If Txt成文机关 = "" Or Txt成文机关 = "—无—" Then
Txt成文机关 = "—无—"
Txt联合单位.Enabled = False
Chk联合发文 = False
Else
Txt联合单位.Enabled = True
End If
Txt成文机关 = Trim(Txt成文机关)
End Sub
Private Sub Txt签发人_AfterUpdate()
If Txt签发人 = "" And Txt签发人 <> "—无—" Then
Txt签发人 = "—无—"
Chk签发人 = False
E