none
Transfer Data between Excel and Word RRS feed

  • Question

  •   Hi

    I have an userform in Excel that have 4 textboxes to enter Company Name, subject, Date and letter ID.  How can I use a button to open a Word Document with textboxes data on top of the page, that the user can type the body of letter there?  the user shouldn’t be able to change textboxes data location or text of them. After save and close the document,How can I add the letter to a list box in that userform? after all, How can I show first 20 charectors of the body of letter, when the user select the letter in the list box?

      Thank you for your

    Monday, January 19, 2015 12:19 PM

Answers

  • Hi Samira s,

    Based on the description, you want to automate Word application in a userform of Excel.

    We can use Word Object model to achieve the goal.

    >> How can I use a button to open a Word Document with textboxes data on top of the page, that the user can type the body of letter there? <<

    We can use Range.InsertAfter to insert the specified text at the end of a range.

    >>the user shouldn’t be able to change textboxes data location or text of them<<

    As far as I know, we can isnert a content control to protect the text being edit.

    >>After save and close the document,How can I add the letter to a list box in that userform? <<

    Here is an userful article about using UserForms in Excel:

    How to use Visual Basic for Applications (VBA) to change UserForms in Excel

    >>How can I show first 20 charectors of the body of letter, when the user select the letter in the list box<<

    Did you want to get the content of Word document based on the select value in the listbox? If I understood corectly, we can use Word Object model to ahcieve the goal.

    Also here are some helpful links for you learing Word developing using VBA:

    Concepts (Word 2013 developer reference)

    How do I... (Word 2013 developer reference)

    Welcome to the Visual Basic for Applications language reference for Office 2013

    Hope it is helpful.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, January 20, 2015 3:45 AM
    Moderator