pasting into embedded excel object

M

mike

I'm trying to do a simple paste into an embedded excel object. I need to
select the cell I want to paste into, but I can't seem to do that. The paste
works... but it pastes into whatever the last selected cell was, which is not
acceptable. This is my code:

Sub PasteIntoExcel()
Dim xlSheet As Excel.Worksheet

Set xlSheet = ActivePage.Shapes("excel").Object.Worksheets(1)

'This next line gives me an error "Activate method of range class failed."
'xlSheet.Range("E2").Activate
'This next line gives me an error "Select method of range class failed."
'xlSheet.Range("E2").Select

xlSheet.Paste
End Sub
 
J

JuneTheSecond

Yes, range class fails.
My alterbative is to use DoCmd and SendKeys like,
Sub EditObject()
Dim shp As Visio.Shape
Dim ex As Excel.Application

Set shp = ActivePage.Shapes(1)
ActiveWindow.Select shp, visSelect
Application.DoCmd visCmdEditOpenObject
DoEvents
Set ex = GetObject(, "excel.application")
Debug.Print ex.ActiveCell.Address
SendKeys "{DOWN}", True
SendKeys "Jorge", True
Debug.Print ex.ActiveCell.Address
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top