我正在构建一个宏,该宏从Word中获取信息并在新的Excel文档中打开它。这是一个以Word开头的Word宏。
Sub Exportwordtoexcel()
Dim wordDoc As Object
Dim oXL As Excel.Application
Dim DocTarget As Word.Document
Dim Target As Excel.Workbook
Dim tSheet As Excel.Worksheet
Set wordDoc = GetObject(, "word.application")
wordDoc.Selection.WholeStory
Selection.Copy
On Error Resume Next
Set oXL = GetObject(, "Excel.Application")
If Err Then
ExcelWasNotRunning = True
Set oXL = New Excel.Application
End If
oXL.Visible = True
Set Target = oXL.Workbooks.Add
Set tSheet = Target.Sheets(1)
tSheet.Paste
End Sub
当我运行此宏时,它将标题放置在我想要的A1中。然后将我的第一段也放在我想要的A2中。不幸的是,当我想将其粘贴到B2中时,它会将下一个段落放在A3中。正确的流程如下:
以此类推,直到我使用的段落数为止。...
我不确定自己在做什么错。任何帮助将不胜感激,