Poll: delete this post

+ Reply to Thread
Results 1 to 14 of 14

Need VBA Help to export data from excel to word as 2 header

  1. #1
    Forum Contributor
    Join Date
    11-25-2015
    Location
    bangalore
    MS-Off Ver
    2019
    Posts
    120

    Need VBA Help to export data from excel to word as 2 header

    Dear experts

    I have data in excel sheet to transpose from excel to word manually i am in need of vba code help ,

    i have set of data which is need to copy first 2 rows only 8 columns A:H paste into word with header point

    The data layer segregate as two layer FY 19-20 one row, FY 21-22 second row
    first two row copy with header paste into word as vertical
    third and fourth row as another segment with header value paste into word
    fifth and sixth row as another segment with header value paste into word


    please find the attachment
    Attached Files Attached Files
    Last edited by julielara; 07-02-2022 at 08:22 PM. Reason: briefing

  2. #2
    Registered User
    Join Date
    06-22-2022
    Location
    India
    MS-Off Ver
    Microsoft office Home and Student 2019
    Posts
    61

    Re: Need VBA Help to export data from excel to word as 2 header

    Hi,

    Please find attached the sheet containing the code to generate the word document as requested.
    If you click on the blue button on the page, the word document will be created as per your specifications.

    Note: Please do not clear the formatting in the range S8:U8 as I have placed the formatting needed to paste the output onto the word doc here.
    Attached Files Attached Files
    Last edited by HariArvi; 07-03-2022 at 07:04 AM.

  3. #3
    Forum Contributor
    Join Date
    11-25-2015
    Location
    bangalore
    MS-Off Ver
    2019
    Posts
    120

    Re: Need VBA Help to export data from excel to word as 2 header

    Hi sir Thanks for your brilliant code it does work for me, i need an extra requirement on same file need to add an images after copy range, sorry for annoying you
    it helps me alot time and accuracy for my project please sir help me

    i just need an add two images after every report range paste in

    i added all images in local folder path:C:\Users\User\Desktop\Oracle_FYIMAGES

    insert images path in col I:I, once click code it would copy from path and paste into word after data pasted

    please find the attachment

    thanks and regards
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    06-22-2022
    Location
    India
    MS-Off Ver
    Microsoft office Home and Student 2019
    Posts
    61

    Re: Need VBA Help to export data from excel to word as 2 header

    Hi,

    I have updated the excel as per your requirement. The code will paste the images in the corresponding pages on the top of the page. You can move the image manually and format it as per your needs.

    Note:
    The image file path shall be with the format of image. For ex.:C:\Users\User\Desktop\Oracle_FYIMAGES\FY_19-20_1.jpg
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    11-25-2015
    Location
    bangalore
    MS-Off Ver
    2019
    Posts
    120

    Re: Need VBA Help to export data from excel to word as 2 header

    Wow!! Its amazing Master you are champion Thanks!! small query images mingle with text values on page, if its comes in proper allignment it would be more helpful
    Attached Images Attached Images
    Last edited by julielara; 07-04-2022 at 05:17 PM. Reason: briefing

  6. #6
    Registered User
    Join Date
    06-22-2022
    Location
    India
    MS-Off Ver
    Microsoft office Home and Student 2019
    Posts
    61

    Re: Need VBA Help to export data from excel to word as 2 header

    Hi, Thank you for your response.

    We have two options. Both need manual intervention. But option 1 as posted in the previous reply is simple. Once the images are pasted you can move and place wherever you want in the page as the image size and resolution may vary. The second option is explained below.

    Option2:
    Refer the File attached(twoheader-With BM)
    There are two codes in the excel. One for populating the table and other for adding the pics below table.
    There are some manual steps to be followed in this option

    Step1: Click the Blue icon in Excel for populating the table in the word document.
    Step2: Once the tables are pasted. Add Bookmarks(BM) in each page for each pic and the BM name shall be same as mentioned in the J column in excel.
    Step3: After adding the BMs, Save the file and type the file path with extension in the cell L1 in excel.
    Step4:Click the orange icon in the excel for the pics to be placed in the corresponding BMs.
    Note: File will be saved after adding the pics in the same location as mentioned above.
    Attached Files Attached Files
    Last edited by HariArvi; 07-05-2022 at 03:13 AM.

  7. #7
    Forum Contributor
    Join Date
    11-25-2015
    Location
    bangalore
    MS-Off Ver
    2019
    Posts
    120

    Re: Need VBA Help to export data from excel to word as 2 header

    Hi sir i am getting error still , please find the excel with path location
    this is my images save location C:\Users\User\Desktop\Booking_price\renamer\build_2\ img.....
    this is my word.doc save location C:\Users\User\Desktop\Report_Generator\JACKFRUIT.docx
    advice me if i am wrong
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by julielara; 07-05-2022 at 10:01 AM. Reason: explaination

  8. #8
    Registered User
    Join Date
    06-22-2022
    Location
    India
    MS-Off Ver
    Microsoft office Home and Student 2019
    Posts
    61

    Re: Need VBA Help to export data from excel to word as 2 header

    Hi,
    1.The image path is not with full image file name. For ex:C:\Users\User\Desktop\Booking_price\renamer\build_2\ADA_BUIL2_001.jpg.
    2. In the column j You need to enter the bookmark name which you use in word document as the location where you want to paste the image.

    To add Bookmark to word follow the following steps:
    1.Once the first macro is done, the tables will be pasted in the word. Open the word document and Go to insert tab and insert bookmark by keeping the cursor in the locations you want the images to be. In each page below the table you will need two book marks as you wanted to paste two images below the table in each page. Name the book marks as Image1, Image2 etc; Like wise do for all the pages and save the file and put the file path as you have done in Cell L1.

    2. Put the same names of the bookmarks you have kept in the word file in the J column.
    3.Click the Second macro. All the pics will be pasted in the bookmarked location.
    Attached Images Attached Images
    Last edited by HariArvi; 07-05-2022 at 11:16 AM.

  9. #9
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,513

    Re: Need VBA Help to export data from excel to word as 2 header

    Experience trumps academics every day of the week and twice on Sunday.

  10. #10
    Forum Contributor
    Join Date
    11-25-2015
    Location
    bangalore
    MS-Off Ver
    2019
    Posts
    120

    Re: Need VBA Help to export data from excel to word as 2 header

    sorry for that i post across forum might be get solution soon for thread by the way of attitude, i delete my account after here never ask free help on forum, sorry to Hariarvi if i hurt your feeling
    thanks all experts

  11. #11
    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: Need VBA Help to export data from excel to word as 2 header

    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  12. #12
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,675

    Re: Need VBA Help to export data from excel to word as 2 header

    Quote Originally Posted by julielara View Post
    sorry for that i post across forum might be get solution soon for thread by the way of attitude, i delete my account after here never ask free help on forum, sorry to Hariarvi if i hurt your feeling
    thanks all experts
    julielara, if you post to another forum we ask that you provide a link so people do not spend time solving a problem that has already been solved somewhere else. Most other forums have the same rule. Please take the time to review our rules. There aren't many, and they are all important.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  13. #13
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: Need VBA Help to export data from excel to word as 2 header

    Quote Originally Posted by julielara View Post
    sorry for that i post across forum might be get solution soon for thread by the way of attitude, i delete my account after here never ask free help on forum, sorry to Hariarvi if i hurt your feeling
    thanks all experts
    Based on your report on this thread...
    i think its not cross post, i posted threads across different forum not same excel forum.

    cross check if come again same excelforum. even forum rules didnt say repeat post across different forum is overrule, dont need send reminder or warning for me.
    The requirement is if you post the same question on DIFFERENT web sites, not just this 1. This is to prevent members wasting their time answering a question which might already have been answered in another site.

    If this requirement means you wish to leave this forum now, that is unfortunate, but it is your choice. Note that you will find teh same requirement on pretty much any forum such as ours.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  14. #14
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,288

    Re: Need VBA Help to export data from excel to word as 2 header

    even forum rules didnt say repeat post across different forum is overrule, dont need send reminder or warning for me.
    Further to Ford's message to you above, the forum rules DO talk about repeat posts across different forums:

    3. Questions that are cross-posted to other web forums must contain links to those posts on those forums or a comment to tell us where else the question has been asked.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

+ 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. How to export data in MS Word to Excel
    By emir_w in forum Excel General
    Replies: 2
    Last Post: 11-05-2019, 03:51 AM
  2. Export data from Excel to word
    By matt.howard in forum Excel General
    Replies: 1
    Last Post: 08-14-2017, 11:28 AM
  3. Extract Word header table data to excel (closed word document)
    By Yakov on Excel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-14-2017, 02:12 PM
  4. Export data from excel to ms word
    By ROHAN999 in forum Excel General
    Replies: 0
    Last Post: 09-19-2013, 12:44 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. Export data from Excel to word
    By delboy2405 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-14-2012, 05:36 AM
  7. Export excel data into word
    By Internoob2 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-20-2011, 02:59 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