![](/img/trans.png)
[英]Copy an Excel range and paste as an image in a Picture Content Control inside a Word doc using VBA
[英]copy word doc footer to excel using vba
尝试使用Excel宏在MS_Word文档中获取页脚文本,然后将其粘贴到Excel工作表中。 此VBA代码适用于MS_WORD,但不适用于MS_EXCEL宏。 我检查并在文档中节数= 1。
Dim wdDoc As Object
Dim h As Object 'Word.HeaderFooter
Dim docver As String 'Paste this to excel
Set wdDoc = GetObject("D:docname.docx")
With wdDoc
For Each h In .Sections
docver = h.Footers(wdHeaderFooterPrimary).Range.Text
Next
End With
我可以使用VBA项目视图下的“监视窗口”来确定语法结构。 正确的语法如下:
对于.Sections.Item.Footers中的每个h
docver = h.Footers.Item(1).Range.Text
下一个
how to I extract a footer for each document. It is only finding the footer for the first document.
Currently my code is
Dim objFSO As Object
Dim objFolder As Object
Dim objFile As Object
Dim i As Integer
Dim docvers As String
'Create an instance of the FileSystemObject
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Get the folder object
Set objFolder = objFSO.GetFolder("U:\word" & "\")
i = 1
strDirectory = "U:\word" & "\"
varDirectory = Dir(strDirectory, vbNormal)
docvers = strDirectory & varDirectory
Dim wdDoc As Object
Dim h As Object 'Word.HeaderFooter
Dim docver As String 'Paste this to excel
Set wdDoc = GetObject(docvers)
With wdDoc
For Each h In .Sections
docver = h.footers.Item(2).Range.Text
Next
End With
For Each objFile In objFolder.Files
'print file name
Cells(i + 1, 1) = objFile.Name
'print file path
Cells(i + 1, 2) = objFile.Path
Cells(i + 1, 3) = docver
i = i + 1
Next objFile
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.