Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
VBA - Assigning Excel Controlsource to Word Userform Checkbox?
Hi all,
I don't often ask questions, but I've hit a bit of a brick wall.
I'm trying to create a fully dynamic userform in Word VBA which pulls data from an excel spreadsheet hidden in the background and allows the user to manipulate the data from the userform. Put simply, I'm wondering if it's possible to assign an excel cell reference to a checkbox controlsource property in a Word Userform? The current code I'm playing with, which if stripped to basics for the purposes of this question, is as follows:
Private Sub UserForm_Initialize()
Dim objExcel As Object
Dim objWB As Object
Set objExcel = CreateObject("Excel.Application")
Set objWB = objExcel.Workbooks.Open ("C:\Spreadsheet.xlsm")
checkbox1.controlsource = objExcel.sheets("Sheet1").Range("D2")
etc.
*Note that the checkbox and range are dynamic and vary every time based on a number of conditions and arrays. I've represented them as absolute references in order to simplify the above.
The issue I'm having is that no matter what combination of code I add to the controlsource property, I am always getting a runtime error 380. I've heard that an excel controlsource cannot be added and that I'd have to load the data to word using the 'value' property, but I want the Word Userform to manipulate the Excel data. Does anyone know whether it's a syntax issue? and if not, can anyone recommend any solutions?
Thanks
2 Answers
- garbo7441Lv 78 years agoFavorite Answer
Hi General,
I played around with your scenario, and I see what you mean. Unfortunately, I could not come up with a solution either. My only suggestion is to try the gurus at the Excel L developer list. That is where I go when stumped. Here is a link that may assist you:
http://www.lsoft.com/scripts/wl.exe?SL1=EXCEL-L&H=...
edit: note that there are two Excel lists on the Peachease forums, Advanced and General. L is advanced.



