Button to launch embedded object

L

Legacy 32120

Guest
Hello folks,

How can I create a single click button to launch an embedded Word document please?

I know how to insert an embedded object but activating it requires double clicking the shape.

With thanks,

Max Kramer :)
 

Leith Ross

Well-known Member
Joined
Mar 17, 2008
Messages
1,872
Office Version
2010, 2007
Platform
Windows
Hello Max,

This macro will launch any embedded Word object on the active sheet.
Code:
Sub LaunchIt()

  Dim Obj As Object
  
    For Each Obj In ActiveSheet.OLEObjects
      If Obj.progID Like "Word*" Then Obj.Activate
    Next Obj
  
End Sub
 
L

Legacy 32120

Guest
Hi Leith,

Thanks muchly for the macro. It works with a (single-click) CommandButton, and launches all the Word objects in the sheet.

However, I should have mentioned that I've multiple Word objects in the sheet and need to launch them only one at a time. Can the code be altered accordingly?

Max
 

Leith Ross

Well-known Member
Joined
Mar 17, 2008
Messages
1,872
Office Version
2010, 2007
Platform
Windows
Hello Max,

If you want to open a single embedded object with a single command button, you can use either the object's name or the collection index number to reference it.

Referencing the Embedded Object by Name
Code:
Sub CommandButton1_Click()
   ActiveSheet.OLEObjects("Object 1").Activate
End Sub
Referencing the Embedded Object by the Collection Index Value
Code:
Sub CommandButon1_Click()
  ActiveSheet.OLEObjects(1).Activate
End Sub
If you want to do something else, let me know.

Sincerely,
Leith Ross
 
L

Legacy 32120

Guest
Hello Leith,

Thanks again....

Cheers for now,

Max :)
 
L

Legacy 32120

Guest
Hello Leith,

Thanks again....

Cheers for now,

Max :)
 

bontemps

New Member
Joined
Jul 13, 2014
Messages
9
This is great information - Would you mind providing the info on how to activate a document that is on a different sheet?
 

Forum statistics

Threads
1,082,575
Messages
5,366,412
Members
400,888
Latest member
Cdim7

Some videos you may like

This Week's Hot Topics

Top