# coding:utf8 import win32com from win32com.client import Dispatch, constants
def getWordAddWatermark(): wordApp = win32com.client.DispatchEx(
"Word.Application") # 打开word进程 wordApp.Visible = True wordApp.DisplayAlerts =
False doc = wordApp.Documents.Add() # 新建一个空白文件 actDoc = wordApp.ActiveDocument
Sect= actDoc.Sections(1).Range.Select() wordApp.ActiveWindow.ActivePane.View.
SeekView= 9 # selectObj = wordApp.Selection wordApp.Selection.HeaderFooter.
Shapes.AddTextEffect(0, "DOt1x © QQ980469001", "等线", 1, False, False, 0, 0).
Select() # shpObj = vart.Select() wordApp.Selection.ShapeRange.Name = '0'
wordApp.Selection.ShapeRange.TextEffect.NormalizedHeight = False wordApp.
Selection.ShapeRange.Line.Visible = False wordApp.Selection.ShapeRange.Fill.
Visible= True wordApp.Selection.ShapeRange.Fill.Solid wordApp.Selection.
ShapeRange.Fill.ForeColor = 0 wordApp.Selection.ShapeRange.Fill.Transparency =
0.5 # 设置颜色 wordApp.Selection.ShapeRange.Fill.ForeColor.ObjectThemeColor = 14
wordApp.Selection.ShapeRange.Fill.ForeColor.TintAndShade = 0 wordApp.Selection.
ShapeRange.Rotation = 315 wordApp.Selection.ShapeRange.LockAspectRatio = True
wordApp.Selection.ShapeRange.Height = 120 wordApp.Selection.ShapeRange.Width =
460 wordApp.Selection.ShapeRange.WrapFormat.AllowOverlap = True #
wordApp.Selection.ShapeRange.WrapFormat.Side = wdWrapNone wordApp.Selection.
ShapeRange.WrapFormat.Type = 3 wordApp.Selection.ShapeRange.WrapFormat.Side = 3
wordApp.Selection.ShapeRange.RelativeVerticalPosition = 0 wordApp.Selection.
ShapeRange.Left = -999995 wordApp.Selection.ShapeRange.Top = -999995 #
这里出问题了,提示没有select这个方法 # wordApp.Selection.HeaderFooter.Shapes("0").Select #
wordApp.Selection.ShapeRange.Duplicate.select #
wordApp.Selection.ShapeRange.IncrementLeft(-426.8) #
wordApp.Selection.ShapeRange.IncrementTop(403.85) # 关闭页眉页脚 wordApp.ActiveWindow.
ActivePane.View.SeekView = 0 actDoc.Save() actDoc.Close() wordApp.Close() if
__name__== '__main__': getWordAddWatermark()

技术
©2019-2020 Toolsou All rights reserved,
过拟合和欠拟合的形象解释2021 美赛时间安排表Springboot之JPA常用查询方法中国月球车“月兔二号”在月球发现一块奇怪岩石PS制作登录界面C语言程序设计课程设计 之《学生成绩管理系统》消息质量平台系列文章|全链路排查篇年薪20万属于什么水平?答案让人扎心!王者荣耀背景故事整合Jsp+Ajax+Servlet+Mysql实现增删改查(一)