Vba 通过Visual Basic在Word中设置属性,包括PDF文件
我已经在Word中编辑了现有的Visual Basic宏,因此可以在Word中插入PDF文档作为对象。现在的问题是,PDF文件没有以其原始格式插入,因此我想调整/保留其原始格式 我目前使用的代码是:Vba 通过Visual Basic在Word中设置属性,包括PDF文件,vba,pdf,ms-word,Vba,Pdf,Ms Word,我已经在Word中编辑了现有的Visual Basic宏,因此可以在Word中插入PDF文档作为对象。现在的问题是,PDF文件没有以其原始格式插入,因此我想调整/保留其原始格式 我目前使用的代码是: Public Sub VervangTekstDoorLogo() ' ' VervangTekstDoorLogo Macro ' ' If ActiveWindow.View.SplitSpecial <> wdPaneNone Then ActiveWin
Public Sub VervangTekstDoorLogo()
'
' VervangTekstDoorLogo Macro
'
'
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveDocument.PageSetup.DifferentFirstPageHeaderFooter = True
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.TypeText Text:="<briefpapier>"
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
With Selection.Find
.Text = "<briefpapier>"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Dim LogoBestandKop As String
Dim LogoBestandVoet As String
LogoBestandKop = "c:\Document.PDF"
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "<briefpapier>"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
End With
Do While Selection.Find.Execute
With Selection.InlineShapes.AddOLEObject(FileName:=LogoBestandKop, LinkToFile:=False)
End With
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Selection.EscapeKey
Loop
'Selection.Find.Execute Replace:=wdReplaceAll
'Selection.Find.Execute Replace:=wdReplaceAll
'ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.InlineShapes.AddOLEObject LogoBestandKop
End Sub
Public Sub-vervangtechstdoorlogo()
'
'VervangTekstDoorLogo宏
'
'
如果ActiveWindow.View.SplitSpecial WDPaneOne,则
活动窗口。窗格(2)。关闭
如果结束
如果ActiveWindow.ActivePane.View.Type=wdNormalView或ActiveWindow_
ActivePane.View.Type=wdOutlineView然后
ActiveWindow.ActivePane.View.Type=wdPrintView
如果结束
ActiveDocument.PageSetup.DifferentitFirstPageHeaderFooter=True
ActiveWindow.ActivePane.View.SeekView=wdSeekCurrentPageHeader
Selection.TypeText文本:=“”
Selection.HomeKey单位:=wdStory
Selection.Find.ClearFormatting
选择。查找
.Text=“”
.Replacement.Text=“”
.Forward=True
.Wrap=wdFindContinue
.Format=False
.MatchCase=False
.MatchWholeWord=False
.MatchWildcards=False
.MatchSoundsLike=False
.MatchAllWordForms=False
以
Selection.Find.Execute
Dim LogoBestandKop作为字符串
Dim LogoBestandVoet作为字符串
LogoBestandKop=“c:\Document.PDF”
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
选择。查找
.Text=“”
.Replacement.Text=“”
.Forward=True
.Wrap=wdFindContinue
以
执行时执行Selection.Find.Execute
带有Selection.InlineShapes.AddOLEObject(文件名:=LogoBestandKop,LinkToFile:=False)
以
ActiveWindow.ActivePane.View.SeekView=WDSeekIndocument
选择.逃逸键
环
'Selection.Find.Execute Replace:=wdReplaceAll
'Selection.Find.Execute Replace:=wdReplaceAll
'ActiveDocument.Sections(1).标题(WDHeaderFooPerprimary).Range.InlineShapes.AddOLEObject LogoBestandKop
端接头
谁能告诉我如何强制宏保持其原始PDF大小?我知道应该为图片对象设置属性,而不是为对象设置属性。插入Word中的任何对象都会自动调整大小,以适应可用的“文本框”——在表格单元格、文本框和页边距内。您可以尝试将页边距设置为0,前提是原始PDF的大小与您尝试将其插入的文档的页面大小相匹配 但请注意,如果PDF文档包含多个页面,则不能强制OLE对象显示所有页面。OLE容器不是这样工作的——在关联的OLE服务器打开对象之前,它们只能显示一个页面