将工作表导出到单词表中会产生一个奇怪的结果

我写了这个macros来导出一个Excel工作表到一个单词表中:

Private Sub Export_Click() 'export to word table Dim objWord As Object Dim objDoc As Object Set objWord = CreateObject("Word.Application") objWord.Visible = True Sheets("export").Visible = True 'make hidden sheet visible Set objDoc = objWord.documents.Add() LastRow = Sheets("export").Range("$G$1").Value 'number of lines to export For i = 1 To LastRow Sheets("export").Rows(i).EntireRow.Copy objWord.Selection.Paste Next i Application.CutCopyMode = False 'clear the clipboard Sheets("export").Visible = 2 'hide the sheet End Sub 

结果是一个奇怪的格式化表 ,单元格越来越宽,底部越来越宽,而原始表格在所有行和列上具有相同的格式。

我该如何解决这个问题?

而不是逐行导出表,您可以一次复制并粘贴整个表。

 Sub Export_Click() 'export to word table Dim objWord As Object Dim objDoc As Object Set objWord = CreateObject("Word.Application") objWord.Visible = True Sheets("export").Visible = True 'make hidden sheet visible Set objDoc = objWord.Documents.Add() lastrow = Sheets("export").Range("$G$1").Value 'number of lines to export Range("A1:F" & lastrow).Copy 'mention the number of columns you want to copy With objWord .Documents.Add .Selection.Paste .Visible = True End With Application.CutCopyMode = False 'clear the clipboard Sheets("export").Visible = 2 'hide the sheet End Sub