From: Dave on 13 Jan 2010 00:36 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.
|
Pages: 1 Prev: Word 2007 Hyperlinking Next: Need Word 2003 code to send email as attachment |