Solved

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

Posted on 2013-11-13
2
832 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
Comment Utility
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
Comment Utility
Many thanks Rorya. That works fine
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Preface: When I started this series, I used the term CommandBars because that is the Office Object class that it discusses. Unfortunately, when Microsoft introduced Office 2007, they replaced the standard Commandbar menus with "The Ribbon" and rem…
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 will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

744 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

15 Experts available now in Live!

Get 1:1 Help Now