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
Solved

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

Posted on 2013-11-13
2
863 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

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

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…
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 how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

856 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