Solved

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

Posted on 2013-11-25
5
433 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
  • 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

808 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