1. Welcome to Chandoo.org Forums. Short message for you

    Hi Guest,

    Thanks for joining Chandoo.org forums. We are here to make you awesome in Excel. Before you post your first question, please read this short introduction guide. When posting or responding to questions please remember our values at Chandoo.org are: Humility, Passion, Fun, Awesomeness, Simplicity, Sharing Remember that we have people here for whom English is not there first language and we need to allow for this in our dealings.

    Yours,
    Chandoo
  2. Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  3. When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

merge data in excel to word

Discussion in 'VBA Macros' started by rohit varma, May 23, 2018.

  1. rohit varma

    rohit varma New Member

    Messages:
    14
    i am facing a problem in merging the data written in yellow boxes in excel sheet to the word document as per fields.

    Attached Files:

  2. Belleke

    Belleke Active Member

    Messages:
    461
    Something in that direction?
    unzip first.
    I changed your doc to a template (dotx)
    See the 2 green lines in the Code (Alt + F11) in the excel file.
    These
    'Requires Tools > References > Microsoft Word xx.0 Object Library !!!!!!
    xx.0 Object Library can be 12.0 Object Library or 16.0 Object Library... or...

    'doc = "C:\Users\xxxx\xxxx\xxxx\PRP.dotx" 'Change to your Dir !!!!!!
    Cheers

    Attached Files:

    sathishsusa and rohit varma like this.
  3. rohit varma

    rohit varma New Member

    Messages:
    14
    the code is running but the problem is it is showing the errror as "file does not exist or renamed".i will upload a screenshoot of that errror.plz go through that and give me a solution.

    Attached Files:

    • 1.png
      1.png
      File size:
      155.9 KB
      Views:
      3
    • 2.png
      2.png
      File size:
      117.2 KB
      Views:
      5
  4. rohit varma

    rohit varma New Member

    Messages:
    14
    i am uploadign one more image where i have added the address location of word document in the vba code you have written
  5. rohit varma

    rohit varma New Member

    Messages:
    14
    hello miss. could you please resolve this issue
  6. rohit varma

    rohit varma New Member

    Messages:
    14
    it is showing another error now as i mentioned in file uploaded.iam uploading
    sceenshoot of that error

    Attached Files:

    • 1.png
      1.png
      File size:
      101.8 KB
      Views:
      5
  7. rohit varma

    rohit varma New Member

    Messages:
    14
    could you say me what should i do to that green lines in a way i can understand.please
  8. Belleke

    Belleke Active Member

    Messages:
    461
    For this line
    Requires Tools > References > Microsoft Word xx.0 Object Library !!!!!!
    Go to the VBA editor (Alt+F11) click Tools then click references and then scroll down and check the checkbox Microsoft Word xx.0 Object Library !!!!!!
    xx is a version
    (mine =Microsoft Word 16.0 Object Library, this depends on your excel version)
    see image
    For this line
    doc = "C:\Users\xxxx\xxxx\xxxx\PRP.dotx" 'Change to your Dir !!!!!!
    Go to the folder where my PRP word document is.(Important use my template, because of the bookmarks!!!)
    Click in the box with the link next to the text, then you will see something like
    C:\Users\ACER\Documents\Bookmark word (this is an example of my laptop)
    Then Replace C:\Users\xxxx\xxxx\xxxx with your result of your line
    C:\Users\ACER\Documents\Bookmark word
    Use my PRP.dotx word template because there are bookmarks in the document.
    Once you are done you can delete this line

    'Requires Tools > References > Microsoft Word xx.0 Object Library !!!!!!
    and in this line delete the apostrof (see the red sign in front of the line and delete the other red part at the back)

    'doc = "C:\Users\xxxx\xxxx\xxxx\PRP.dotx" 'Change to your Dir !!!!!!
    I hope it is clearer now.

    Attached Files:

    Last edited: May 26, 2018
  9. rohit varma

    rohit varma New Member

    Messages:
    14
    hey thank you.It's working now but you changed the format of my word document.coul u please check over that or guide me how to change that.
    The format i want is as in "new documents" but u have changed that, like in prp.docx

    Attached Files:

  10. rohit varma

    rohit varma New Member

    Messages:
    14
    i tried a lot but i was unable to change the format because it contains your bookmarks
  11. Belleke

    Belleke Active Member

    Messages:
    461
    Go to File -> Options -> look for Show bookmarks (I can't give you more details because I am working with a Dutch office) Then you will see the bookmarks in the document, just do the same with your file.
  12. rohit varma

    rohit varma New Member

    Messages:
    14
    that’s ok.Thank you for doing this to me.
  13. rohit varma

    rohit varma New Member

    Messages:
    14
    hehe its working.Thank you do much buddy
    Sooo nice of you
  14. rohit varma

    rohit varma New Member

    Messages:
    14
    hey while i am creating a new file "prp no" and "ie no" are creating in text format.which code has to be added to change it to number format and where to add that code

    Attached Files:

    • 1.png
      1.png
      File size:
      129.7 KB
      Views:
      7

Share This Page