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

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,218,899
Messages
6,145,093
Members
450,590
Latest member
Naneng

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