[英]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.