Solved

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

Posted on 2013-11-25
5
437 Views
Last Modified: 2013-11-25
Hi,

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
Value
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.

Thanks
Toco
0
Comment
Question by:Tocogroup
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 76

Expert Comment

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

Author Comment

by:Tocogroup
ID: 39674846
0
 
LVL 50

Accepted Solution

by:
Rgonzo1971 earned 250 total points
ID: 39674907
Hi,

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
WD.Quit
Set WD = Nothing

End Sub

Open in new window

Regards
0
 
LVL 76

Assisted Solution

by:GrahamSkan
GrahamSkan earned 250 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
0
 

Author Closing Comment

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

It works fine. Much appreciated.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Suggested Solutions

Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

763 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