+ Reply to Thread
Results 1 to 2 of 2

Exporting from Excel to Word with Header Image Location Issue

  1. #1
    Registered User
    Join Date
    04-20-2022
    Location
    USA
    MS-Off Ver
    O365
    Posts
    3

    Unhappy Exporting from Excel to Word with Header Image Location Issue

    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
    Attached Files Attached Files

  2. #2
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Exporting from Excel to Word with Header Image Location Issue

    Cross-posted at: https://stackoverflow.com/questions/...er-image-issue
    Please read Excel Forum's Cross-Posting policy in rule 3: http://www.excelforum.com/forum-rule...rum-rules.html
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Excel footer image file location
    By bhuvanashriram in forum Excel General
    Replies: 6
    Last Post: 08-25-2016, 07:20 AM
  2. Exporting image, dynamic image in header
    By jakopak in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-10-2015, 04:00 AM
  3. Exporting image, dynamic image in header
    By jakopak in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-10-2015, 03:52 AM
  4. [SOLVED] How to apply Image borders to an image that my excel vba userform pastes in a word doc?
    By CaptainCool in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-11-2014, 05:40 PM
  5. Using EXCEL VBA to create word ,insert header in word, add textbox in header and fill pic
    By xiaorenwuhyl in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-28-2013, 05:32 AM
  6. Exporting image files stored in access to excel
    By EXCEL123456 in forum Excel General
    Replies: 0
    Last Post: 02-14-2012, 02:34 PM
  7. [SOLVED] Exporting EXCEL Graphs as .gif (image file) using VBA or VB
    By haresh7263 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-10-2005, 10:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1