#1
|
|||
|
|||
Populate Combobox from Excel into a Word UserForm
I would like to create a UserForm that includes a combobox populated from data in an excel spreadsheet. After that, I'd like to insert that data into a Word document. I think I know how to handle the second half, but I'm having a tough time figuring out how to populate the combobox with the excel data.
Any assistance would be greatly appreciated. |
#2
|
||||
|
||||
See the example code at http://www.gmayor.com/Userform_ComboBox.html
For the writing of data to the document see the FillBM function which you can find on my web site also.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
Thank you so much for that link. Your code is great. I do have one question.
I'm trying to use this as a letterhead application. So, instead of the words being placed where the cursor is, they would be aligned by the page. I think I know how to accomplish that, but my question is, is there a way to basically select all the text you just added and replace it with other text. Right now, it seems the form only will pull the data once or at the least just add a subsequent choice to the document. But I'd like to replace the text instead of adding new text. Is that possible? Again, thank you so much. |
#4
|
||||
|
||||
If you bookmark the area you want to replace, the FillBM function will replace that bookmarked text with whatever you instruct it to. Run the userform again and it will replace the text again.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
Tags |
combobox, populate, vba |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Using combobox to pass data from an Excel spread sheet to text boxes on userform | Stewie840 | Word VBA | 14 | 12-17-2015 10:13 PM |
Trying to populate Word bookmarks with excel UserForm | smd1112 | Excel Programming | 7 | 09-03-2014 09:42 PM |
VB code: populate combobox from columns in Excel file | billybeach | Outlook | 2 | 04-27-2013 04:38 AM |
how to populate textbox based on combobox selection in word | IvanGeorgiev | Word | 1 | 02-21-2013 07:32 PM |
how to populate textbox based on combobox selection in word | IvanGeorgiev | Word VBA | 1 | 02-21-2013 07:28 PM |