Solved

Does Excel VBA support the ActiveX label control in Word 2010 documents ?

Posted on 2013-11-13
2
848 Views
Last Modified: 2013-11-13
Hi,

This is a similar problem I've had before but in a different scenario.

I have an Excel 2010 macro which, on a click of a button:
   1. Opens a Word 2010 document
   2. Takes values from the Excel sheet and populates ActiveX label control placeholders in the Word document.

I'm getting an 'Error 438 Object doesn't support this method or property' when it tries to populate the first label on the Word document.

I have selected the 'Microsoft Excel 14.0 Object Library' entry in Tools --> References and have attached the Excel workbook (TD9.xlsm) and the Word document (ET9.docx).

My questions are:
Why do I get an Error 438 on a Word label control ?
Does it matter if the Word document is either a .docx or a .docm (given it only contains controls and no actual code) ?

Thanks for your help
TD9.xlsm
ET9.docx
0
Comment
Question by:Tocogroup
2 Comments
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 500 total points
ID: 39644105
The labels are not members of the Application object - they belong to the document:
Private Sub cbEnquiryLetter_Click()

   Dim WordApp As Object
   Dim WordDoc As Object
   Set WordApp = CreateObject("Word.Application")
   Set WordDoc = WordApp.Documents.Open("C:\Users\Toco\Desktop\ET9.docx")
   WordApp.Visible = True
   
   With WordDoc
      .laClient.Caption = "Enquiry from " & Sheets("Training").Cells(4, 9)
      .lacourseType.Caption = "Re. One-to-One Training - " & Sheets("Training").Cells(4, 8)
      .laTodaysDate.Caption = Format(Now, "dd mmmm yyyy")
      .laContactTitle.Caption = "Dear " & Sheets("Training").Cells(4, 10) & ","
   End With

End Sub

Open in new window

0
 

Author Closing Comment

by:Tocogroup
ID: 39644258
Many thanks Rorya. That works fine
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Introduction This tutorial provides instructions on how to properly format your Word document using the inbuilt tools provided. The benefits of using these tools means your documents are more accessible and easily portable to other applications an…
Microsoft Word is a program we have all encountered at some point, but very few of us have dug deep into its full scope of features, let alone customized it to suit our needs. Luckily making the ribbon (aka toolbar, first introduced in Word 2007) wo…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
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…

813 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

18 Experts available now in Live!

Get 1:1 Help Now