admin管理员组文章数量:1315290
We have a VBA macro that let the users add headers to word documents from a list from files. It pretty much only adds the file as a shape. See code below. This worked for at least 15 years, but since last december it broke. The 'border' for the inserted shape was directly top- left of the first letter or picture in the file. See screenshot. (All headers are stored as .doc files)
But now the 'border' is correct for some files, but for other it's far more to the top and left. See screenshot.
We did not change anything in the code and also did not change the files. I'm not sure if the could be related to a word update. Did anything change in Word that the AddOLEObject uses different selections of the file handed over?
Can somebody help?
Set oShape = ActiveDocument.Shapes.AddOLEObject(fileName:=header...
Private Sub addHeader()
header = "pathtoheaderfile"
Selection.GoTo What:=wdGoToPage, Which:=wdGoToAbsolute, Count:=1
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Set oShape = ActiveDocument.Shapes.AddOLEObject(fileName:=header _
, LinkToFile:=False _
, DisplayAsIcon:=False _
, Anchor:=Selection.Range)
With oShape
.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
.Left = CentimetersToPoints(2)
.RelativeVerticalPosition = wdRelativeVerticalPositionPage
.Top = CentimetersToPoints(1)
.LockAnchor = True
.WrapFormat.AllowOverlap = True
.WrapFormat.Side = wdWrapBoth
.WrapFormat.DistanceTop = CentimetersToPoints(0)
.WrapFormat.DistanceBottom = CentimetersToPoints(0)
.WrapFormat.DistanceLeft = CentimetersToPoints(0)
.WrapFormat.DistanceRight = CentimetersToPoints(0)
.WrapFormat.Type = 5
End With
End Sub
本文标签: ms wordVBA adding Header method bug since december 2024Stack Overflow
版权声明:本文标题:ms word - VBA adding Header method bug since december 2024 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741978149a2408241.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论