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 :)
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
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
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0
This is great information - Would you mind providing the info on how to activate a document that is on a different sheet?
 
Upvote 0

Forum statistics

Threads
1,214,583
Messages
6,120,380
Members
448,955
Latest member
BatCoder

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top