Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


How do I populate a Word 2010 HTMLText box from Excel ?

Posted on 2013-11-25
Medium Priority
Last Modified: 2013-11-25

I've been sent a Word document with a number of input form fields. However, they don't appear to be legacy or ActiveX label or text box controls as when I check their properties they have far few attributes, for example...

Name DefaultOcxName9 (HTML TextArea)
Columns 39
Height 102.75
HTMLName ctl00$ContentMain$RoomContactForm$TbAddress
Rows 8
Width 170.25
WordWrap OFF

What sort of controls are these ? And how do I refer to them in Excel VBA if I want to populate them from a worksheet.

Question by:Tocogroup
  • 2
  • 2
LVL 77

Expert Comment

ID: 39674612
Can you post the document (or a relevant bit of it), so we can see exactly what it is, please?

Author Comment

ID: 39674846
LVL 54

Accepted Solution

Rgonzo1971 earned 1000 total points
ID: 39674907

pls try this way

Sub test()
Dim WD As Object
Set WD = CreateObject("Word.Application")
WD.Visible = True
WD.Documents.Open "D:\test.doc"
WD.ActiveDocument.DefaultOcxName10.Value = Range("A1")  '"myName"
WD.ActiveDocument.DefaultOcxName9.Value = Range("A2")  '"myAddress"

WD.Documents("D:\test.doc").Close SaveChanges:=True
Set WD = Nothing

End Sub

Open in new window

LVL 77

Assisted Solution

GrahamSkan earned 1000 total points
ID: 39674911
Thanks. They are ActiveX controls than can be addressed directly by name, e.g.
doc.DefaultOcxName9.value = "abc" & vbcr & "def"
where doc is a Word document object

Author Closing Comment

ID: 39674960
Thanks for your combined efforts - code and explanation.

It works fine. Much appreciated.

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question