writing to an embeded object

teamsimpson

New Member
Joined
Sep 20, 2002
Messages
22
i have an embeded object in sheet 1 of my worksheet, i use a hyperlink to another excell, to copy the contents of a worksheet, then i double click on the embedded object and then paste the data.
I have tried recording a macro, but it doesnot like double clicking to open an embeded object, so i edited the macro using OBObjects Activate, which works but i cant paste the contents of my clipboard and then close the embededobject.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Ivan F Moala

MrExcel MVP
Joined
Feb 10, 2002
Messages
4,209
Don't know waht your object is but here is one way o do this;

EDIT: (Thanks DK)<pre/>
Sub PasteObj()
Dim obj As Object

'// copy
Range("C9:D10").Copy

Application.DisplayAlerts = False
'// Check the actual index of your Object!
'// and adjust accordingly
Set obj = Sheet1.OLEObjects(1)
obj.Verb Verb:=xlPrimary
'// Now paste!
SendKeys ("^V"), True

With Application
.DisplayAlerts = True
.CutCopyMode = False
End With

Set obj = Nothing

End Sub</pre>


_________________
Kind Regards,<font size=+2><font color="red"> I<font color="blue">van<font color="red"> F M</font color="blue">oala</font><font size=1> From the City of Sails
image.gif

This message was edited by Ivan F Moala on 2002-09-21 12:57
 

dk

MrExcel MVP
Joined
Feb 15, 2002
Messages
2,942
Nice code Ivan :)

However, shouldn't it be

obj.Verb Verb:=xlPrimary ?
 

Ivan F Moala

MrExcel MVP
Joined
Feb 10, 2002
Messages
4,209

ADVERTISEMENT

What the hell !? :biggrin:

Nice catch

Thanks DK
 

teamsimpson

New Member
Joined
Sep 20, 2002
Messages
22
I could'nt get the code you wrote to work.Could you look at the code i nearley got to work, my problem is, the macro reads an outside excel file and puts it in an embeded object,it sizes the shape and renames it from new to data1.my problem is, the next time i run the macro, it can't handle the names, i think i need a loop or if else statement, see below
Sheets(1).OLEObjects.Add(Filename:="file.xls", Link:=False).Name = "new"
With Sheets(1).OLEObjects("new")
.Left = 100
.Top = 100
.Width = 50
.Height = 30
ActiveSheet.Shape("new").Name = "data1"
End With
Sheets(1).[a1].Active
End Sub
 

Forum statistics

Threads
1,148,020
Messages
5,744,359
Members
423,863
Latest member
teehexcel

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
Top