|
本帖最后由 413191246se 于 2024-1-18 21:07 编辑
* 近来发觉不少人都利用手机传送 Word 文档和 PDF 文档,并且添加电子印章和电子文件头,不想打印!我最近两天反复折腾了一下电子文件头,效果还不错!好东东不敢独享,分享出来供大家参考!
* 在落款处插入电子印章宏,我也做了,但是只是个半成品(还有手动成分),暂不分享了。
* 请注意:可以设置常用高频的宏为热键(比如 F8),或将宏做成按钮放在工具栏或快速访问工具栏上。
* 再请注意:宏仅适用于排版后的公文,首段要空白 21 磅,页边距是默认 A4 (2.54cm/3.17cm)纸张。
* 可以在我的代码基础上,修改参数,慢慢调试,形成自己的电子文件头。
* Word 文档转换为 PDF 文档,建议试试免费软件 TinyPDF。
* 请将代码复制到空白文档后,全选,剪切,再粘贴到 VBE 中,以防乱码。
* 更新:党委、便笺两个宏,更改了一下图形出现顺序,使图形组合起来,方便移动对齐。
- Sub eFileHead_Company()
- '电子文件头(公司)--需要自行添加发文字号,如:某某发〔2024〕1号
- Selection.HomeKey 6
- With ActiveDocument
- With .Paragraphs(1).Range
- .Font.Size = 21
- .InsertAfter Text:=vbCr & vbCr & vbCr
- End With
- .Paragraphs(6).Range.Font.Size = 26
- With .Shapes.AddTextbox(msoTextOrientationHorizontal, _
- 92, 60.4, 413, 88.4)
- .Line.Visible = msoFalse
- .Select
- Selection.ShapeRange.Left = wdShapeCenter
- With .TextFrame.TextRange
- .Text = "某某市电子科技大学文件"
- With .Font
- .Name = "华文中宋"
- .Size = 48
- .Bold = True
- .Color = wdColorRed
- .Scaling = 70
- End With
- With .ParagraphFormat
- .Alignment = wdAlignParagraphCenter
- .Alignment = wdAlignParagraphDistribute
- End With
- End With
- End With
- With .Shapes.AddLine(92#, 197#, 507#, 197#)
- .Select
- With Selection.ShapeRange
- .Left = wdShapeCenter
- .Line.ForeColor.RGB = RGB(255, 0, 0)
- .Line.Weight = 1.25
- End With
- End With
- End With
- Selection.HomeKey
- End Sub
- Sub eFileHead_Committee()
- '电子文件头(党委)--需要自行添加发文字号,如:某某委发〔2024〕1号
- Selection.HomeKey 6
- With ActiveDocument
- With .Paragraphs(1).Range
- .Font.Size = 21
- .InsertAfter Text:=vbCr & vbCr & vbCr
- End With
- .Paragraphs(6).Range.Font.Size = 26
- With .Shapes.AddLine(92#, 197#, 507#, 197#)
- .Select
- With Selection.ShapeRange
- .Left = wdShapeCenter
- .Line.ForeColor.RGB = RGB(255, 0, 0)
- .Line.Weight = 1.25
- End With
- End With
- .Shapes.AddShape(msoShapeRectangle, 281.6, 189#, 30.75, 23.4).Select
- Selection.ShapeRange.Line.Visible = msoFalse
- .Shapes.AddShape(msoShape5pointStar, 286.6, 188.8, 20.75, 19.95).Select
- With Selection.ShapeRange
- .Line.ForeColor.RGB = RGB(255, 0, 0)
- .Fill.ForeColor.RGB = RGB(255, 0, 0)
- End With
- End With
-
- ActiveDocument.Shapes.SelectAll
- Selection.ShapeRange.Group.Select
-
- With ActiveDocument.Shapes.AddTextbox(msoTextOrientationHorizontal, _
- 92, 60.4, 413, 88.4)
- .Line.Visible = msoFalse
- .Select
- Selection.ShapeRange.Left = wdShapeCenter
- With .TextFrame.TextRange
- .Text = "中共某某市股份有限公司委员会"
- With .Font
- .Name = "华文中宋"
- .Size = 48
- .Bold = True
- .Color = wdColorRed
- .Scaling = 55
- End With
- With .ParagraphFormat
- .Alignment = wdAlignParagraphCenter
- .Alignment = wdAlignParagraphDistribute
- End With
- End With
- End With
- Selection.HomeKey 6
- End Sub
- Sub eFileHead_Memo()
- '电子文件头(便笺)
- With Selection
- .HomeKey 6
- .Paragraphs(1).Range.Font.Size = 21
- .TypeText Text:=vbCr & vbCr & vbCr
- End With
- With ActiveDocument.Shapes.AddLine(92#, 150#, 507#, 150#)
- .Select
- With Selection.ShapeRange
- .Left = wdShapeCenter
- .Line.ForeColor.RGB = RGB(255, 0, 0)
- .Line.Weight = 2.5
- End With
- End With
- With ActiveDocument.Shapes.AddLine(92#, 154#, 507#, 154#)
- .Select
- With Selection.ShapeRange
- .Left = wdShapeCenter
- .Line.ForeColor.RGB = RGB(255, 0, 0)
- .Line.Weight = 1.25
- End With
- End With
-
- ActiveDocument.Shapes.SelectAll
- Selection.ShapeRange.Group.Select
- Selection.HomeKey 6
-
- With ActiveDocument.Shapes.AddTextbox(msoTextOrientationHorizontal, _
- 92, 60.4, 413, 78.4)
- .Line.Visible = msoFalse
- .Select
- Selection.ShapeRange.Left = wdShapeCenter
- With .TextFrame.TextRange
- .Text = "某某市商贸股份公司"
- With .Font
- .Name = "华文中宋"
- .Size = 48
- .Bold = True
- .Color = wdColorRed
- .Scaling = 80
- End With
- With .ParagraphFormat
- .Alignment = wdAlignParagraphCenter
- .Alignment = wdAlignParagraphDistribute
- End With
- End With
- End With
- Selection.HomeKey 6
- End Sub
复制代码
|
|