+ Reply to Thread
Results 1 to 19 of 19

Creating report from Excel to Word

  1. #1
    Forum Contributor
    Join Date
    04-28-2014
    Location
    Sverige
    MS-Off Ver
    Excel 2010
    Posts
    221

    Creating report from Excel to Word

    Hi the following code is used to export values form Excel into a word document:

    Please Login or Register  to view this content.

    The report obtained then looks like this:

    Excelforum.jpg


    How can I make the values fit within the margins of the word document? Would appreciate any kind of help rewriting my code.
    Last edited by RinorM; 06-02-2014 at 08:07 AM.

  2. #2
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Creating report from Excel to Word

    hi RinorM, try to change the following line:
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    04-28-2014
    Location
    Sverige
    MS-Off Ver
    Excel 2010
    Posts
    221

    Re: Creating report from Excel to Word

    Hi! unfortunately that didnt work. I will paste the document if you got time to check it please. Thank you.

    Excelforum help.xlsm

  4. #4
    Forum Contributor
    Join Date
    04-28-2014
    Location
    Sverige
    MS-Off Ver
    Excel 2010
    Posts
    221

    Re: Creating report from Excel to Word

    I have edited the code above into a newer version where this should adjust the margins but it wont:

    Please Login or Register  to view this content.
    Last edited by RinorM; 06-02-2014 at 08:06 AM.

  5. #5
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Creating report from Excel to Word

    try this out:

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    04-28-2014
    Location
    Sverige
    MS-Off Ver
    Excel 2010
    Posts
    221

    Re: Creating report from Excel to Word

    Hi watersev! It became better but it still gets outside the margins:

    Excelforum.jpg

    Thank you for your time and help!

  7. #7
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Creating report from Excel to Word

    my end it is looking OK on the provided xlsm file, please see attached
    Attached Files Attached Files

  8. #8
    Forum Contributor
    Join Date
    04-28-2014
    Location
    Sverige
    MS-Off Ver
    Excel 2010
    Posts
    221

    Re: Creating report from Excel to Word

    Yes I see, but do you know why the microsoft equation formulas get so strange format? Becase the code I had copied the whole formula but yours takes somekind of printscreen of it? Thank you.

  9. #9
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Creating report from Excel to Word

    the last line controls that
    Please Login or Register  to view this content.

  10. #10
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Creating report from Excel to Word

    try to right-click the table your end, Autofit - Autofit Contents, it should correct table over the margin issue your end

  11. #11
    Forum Contributor
    Join Date
    04-28-2014
    Location
    Sverige
    MS-Off Ver
    Excel 2010
    Posts
    221

    Re: Creating report from Excel to Word

    I managed to rewrite the code abit so it looks like this:

    Please Login or Register  to view this content.
    Only thing is that now it creates two word documents. I believe it is becase of this sentence is mentioned twice :


    Please Login or Register  to view this content.
    How can I rewrite that one so that it doesn't appear two word documents when running the Macro? Thank you.

  12. #12
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Creating report from Excel to Word

    it should be
    Please Login or Register  to view this content.
    instead of the line in question

    I do not see how that rectifies the issue of the table over the margin. Though if you are OK with that I do not mind (I can suggest the way it would work as you want in case I'm right)

  13. #13
    Forum Contributor
    Join Date
    04-28-2014
    Location
    Sverige
    MS-Off Ver
    Excel 2010
    Posts
    221

    Re: Creating report from Excel to Word

    Sorry for changing subject. The code I pasted manages to give me that the tables are inside of the page, but how can I make it so that I want to narrow the width of the tables pasted? btw i really appreciate the time you take to help me.

  14. #14
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Creating report from Excel to Word

    the following code goes to Excel file:

    Please Login or Register  to view this content.
    This code goes to Word Normal.dot that keeps Word macros similar to Excel personal macro book:

    Please Login or Register  to view this content.
    This way it allows to set parameters for Word by it's native code as I've not found a way to control them from Excel

  15. #15
    Forum Contributor
    Join Date
    04-28-2014
    Location
    Sverige
    MS-Off Ver
    Excel 2010
    Posts
    221

    Re: Creating report from Excel to Word

    OK lets see if I got this straight. The first code I paste it in Excel and the second one I paste it in Word? If I Choose to use this excel file in another computer, will it work then?
    Last edited by RinorM; 06-02-2014 at 12:10 PM.

  16. #16
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Creating report from Excel to Word

    if you do not take Normal.dot for Word it will error out on the calling line and you will end up with everything done except for putting text horizontal and setting table within page margins

  17. #17
    Forum Contributor
    Join Date
    04-28-2014
    Location
    Sverige
    MS-Off Ver
    Excel 2010
    Posts
    221

    Re: Creating report from Excel to Word

    Yes I understand, thank you. And there isn't any other way to do the text horizontal and setting table within page margins, without taking the Normal.dot for word?

  18. #18
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Creating report from Excel to Word

    yes, it's possible, give that a try:

    Please Login or Register  to view this content.
    Last edited by watersev; 06-02-2014 at 04:48 PM.

  19. #19
    Forum Contributor
    Join Date
    04-28-2014
    Location
    Sverige
    MS-Off Ver
    Excel 2010
    Posts
    221

    Re: Creating report from Excel to Word

    Oh my god, finally it works!! I am extremly thankful for your time and bearing with me the whole way. THANK YOU!!

+ 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. Header when creating report from Excel to Word
    By RinorM in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-30-2014, 03:52 PM
  2. Creating report in word with VBA
    By RinorM in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-28-2014, 10:57 AM
  3. Creating a report in Excel.
    By nokia6100 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-18-2014, 09:43 AM
  4. Creating a Word Report from Excel Data
    By donnarenia in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-12-2013, 02:09 AM
  5. Combined Excel & Word Report
    By Alan Stuart in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-03-2010, 03:37 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