Hello,
Thank you for reading my post. As you can see in the attached workbook, I'm trying to write code that will export an Excel sheet into Word, and create a header with an image in that Word document. I need the header image in the Word document to be aligned to the right side of the page. Currently, I can only get it to paste the header image on the left side of the header.
The issue is, the code creates a header table within the Word file, but it will only paste the header image into column 1. I'm hoping someone can tell me how to get it to paste the image into column 2 of the header table.
Thank you!
Sub Export()
Dim obj As Object
Dim newobj As Object
Set obj = CreateObject("Word.Application")
obj.Visible = True
Set newobj = obj.Documents.Add
Sheets("Sheet1").Cells.Copy
newobj.Range.Paste
Application.CutCopyMode = False
obj.Activate
With obj
.Visible = True
With newobj
Set wdRng = .Sections(1).Headers(1).Range
Set wdTbl = .Tables.Add(Range:=wdRng, NumRows:=4, NumColumns:=2)
With wdTbl
ThisWorkbook.Sheets("Header_Image").Shapes(1).CopyPicture xlScreen, xlBitmap
.cell(1, 2).Range.PasteSpecial
End With
End With
End With
End Sub
Bookmarks