VBA Selection.InsertFile 在末尾另外添加 NewLine
我正在尝试使用以下代码导入一些Word文档作为页脚。不幸的是,selection.insertfile 函数会在页脚末尾另外插入一个新行。可以去掉吗?我尝试了很多事情,但没有结果。
Public Sub AutoOpen()
'Fußzeile aktualisieren
Call UpdateFooter
End Sub
'Fußzeile für alle Seiten editieren
Sub UpdateFooter()
Application.ScreenUpdating = False
Dim oDoc As Word.Document, oSec As Word.section, rng As Word.Range
Set oDoc = ActiveDocument
For Each oSec In oDoc.Sections
Set rng = oSec.Footers(Word.WdHeaderFooterIndex.wdHeaderFooterFirstPage).Range
AddFooterToRange rng
'oSec.Footers(Word.WdHeaderFooterIndex.wdHeaderFooterFirstPage).Range.Font.Size = 5
Set rng = oSec.Footers(Word.WdHeaderFooterIndex.wdHeaderFooterPrimary).Range
AddFooterToRange rng
'oSec.Footers(Word.WdHeaderFooterIndex.wdHeaderFooterPrimary).Range.Font.Size = 5
Set rng = oSec.Footers(Word.WdHeaderFooterIndex.wdHeaderFooterEvenPages).Range
AddFooterToRange rng
'oSec.Footers(Word.WdHeaderFooterIndex.wdHeaderFooterEvenPages).Range.Font.Size = 5
Next oSec
Application.ScreenUpdating = True
End Sub
'Fußzeilendatei einfügen
Private Sub AddFooterToRange(rng As Word.Range)
With rng
.InsertFile "...fusszeile.docx"
End With
End Sub
提前致谢。
I am trying to import some word documents as footer with the following code. Unfortunately, the selection.insertfile function inserts additionally a new line at the end of the footer. Is it possible to remove it? I've tried many things, without a result.
Public Sub AutoOpen()
'Fußzeile aktualisieren
Call UpdateFooter
End Sub
'Fußzeile für alle Seiten editieren
Sub UpdateFooter()
Application.ScreenUpdating = False
Dim oDoc As Word.Document, oSec As Word.section, rng As Word.Range
Set oDoc = ActiveDocument
For Each oSec In oDoc.Sections
Set rng = oSec.Footers(Word.WdHeaderFooterIndex.wdHeaderFooterFirstPage).Range
AddFooterToRange rng
'oSec.Footers(Word.WdHeaderFooterIndex.wdHeaderFooterFirstPage).Range.Font.Size = 5
Set rng = oSec.Footers(Word.WdHeaderFooterIndex.wdHeaderFooterPrimary).Range
AddFooterToRange rng
'oSec.Footers(Word.WdHeaderFooterIndex.wdHeaderFooterPrimary).Range.Font.Size = 5
Set rng = oSec.Footers(Word.WdHeaderFooterIndex.wdHeaderFooterEvenPages).Range
AddFooterToRange rng
'oSec.Footers(Word.WdHeaderFooterIndex.wdHeaderFooterEvenPages).Range.Font.Size = 5
Next oSec
Application.ScreenUpdating = True
End Sub
'Fußzeilendatei einfügen
Private Sub AddFooterToRange(rng As Word.Range)
With rng
.InsertFile "...fusszeile.docx"
End With
End Sub
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您只需删除页脚中的最后一段即可。
You just need to delete the last paragraph in the footer.