Excel embedded in Word and Select range to copy

D

Dave

Hello,

I have been looking into how I can select an embedded excel doc in Word 2007
and copy all the details in the worksheet to a bookmark in the active
document.

I have managed to open the embedded workbook but I am now stuck. Code so
far is :

Sub ActivateExcelCell()
Dim ils As Word.InlineShape
Dim doc As Word.Document
Dim of As Word.OLEFormat
Dim xlWB As Excel.Workbook
Dim xlapp As Excel.Application

Set of = ActiveDocument.Range.InlineShapes(1).OLEFormat
of.DoVerb wdOLEVerbPrimary
Set xlWB = of.Object
'Put your Excel code here
xlWB.Worksheets(2).Select
xlWB.Worksheets(2).Copy

Set xlWB = Nothing
xlapp.Quit

End Sub

All the
xlWB.Worksheets(2).Select
xlWB.Worksheets(2).Copy

does is makes a copy of the worksheet.

Can anyone tell me how I can select all the data in the worksheet and paste
it into word?

I will also want to make the worksheet a variable based on a userform. e.g I
will have a drop down combo box which will match the worksheet name so I can
tell it which worksheet to copy.

At the moment I am trying to keep it basic by using (1), (2) etc to point at
the worksheet.

Any assistance is appreciated.
 

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