Hello,
I've been trying to figure this out for a while now, but just can't seem to figure it out.
The goal is to simply extract excel sheets into word keeping the same format as it is in the excel sheets, including the header (which is an image), and a footer.
With my current code, the information is copied but completely misaligned and the page breaks are also not correct. Moreover, although I am using the UsedRange function, the header and footer are not being copied over to Word.
Any help would be much appreciated! Please find attached an example excel sheet and also the current word document result I am getting now.
Thank you so much in advance!
I've been trying to figure this out for a while now, but just can't seem to figure it out.
The goal is to simply extract excel sheets into word keeping the same format as it is in the excel sheets, including the header (which is an image), and a footer.
With my current code, the information is copied but completely misaligned and the page breaks are also not correct. Moreover, although I am using the UsedRange function, the header and footer are not being copied over to Word.
Any help would be much appreciated! Please find attached an example excel sheet and also the current word document result I am getting now.
Thank you so much in advance!
Code:
Option Explicit
Sub CreateBasicWordReport()
Dim wdApp As Word.Application
Set wdApp = New Word.Application
Dim tbl As Excel.Range
Dim SrcePath As String
With wdApp
.Visible = True
.Activate
.Documents.Add
End With
Set tbl = ThisWorkbook.Worksheets(Sheet1.Name).UsedRange
tbl.Copy
wdApp.Selection.Paste
End Sub
Sub CreateBasicWordReportAutoInstancing()
Dim wdApp As New Word.Application
If wdApp Is Nothing Then
MsgBox "Word doesn't exist"
End If
wdApp.Visible = True
wdApp.Activate
End Sub