Solved

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

Posted on 2013-11-25
5
428 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 48

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This is written from a 'VBA for MS Word' perspective, but I am sure it applies to most other MS Office components where VBA is used.  One thing that really bugs me is slow code, ESPECIALLY when it's mine!  In programming there are so many ways to…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now