PDA

View Full Version : Sleeper: Inserting Excel OLE Object



raven000
08-19-2005, 07:26 AM
Hi,

I saw an example in this forum to push changes from Excel to Word, and modified it slightly to inste excel table(OLE tables) from Excel to Word. I can get it work for inserting the entire table, but would it be possible to insert just a portion of the table? i.e. i have a huge spreadsheet, but I want to display just the first two columns in Word....

Thanks you for the response.

Aga

Here is my code from Excel


Public Sub rnn()
Dim rng As Object
Dim wdApp As Object
Set wdApp = CreateObject("Word.Application")
Dim wddoc As Object
Set wddoc = wdApp.Documents.Add("c:\del.doc")
Dim bkMark As Object
Dim bkMarks As Object
Set bkMarks = wddoc.Bookmarks
For Each bkMark In bkMarks
Debug.Print bkMark.Name
If (bkMark.Name = "img_bk") Then
Set rng = bkMark.Range
End If
Next bkMark
' rng.InlineShapes.AddPicture "C:\Projects\VisualScreen_2BETA\Code\vs_logo.jpg", , , rng
rng.InlineShapes.AddOLEObject , "c:\someexcel.xml", , , , , , rng
wddoc.SaveAs "c:\del_modified.doc"
wddoc.Close
Set wddoc = Nothing
Set wdApp = Nothing
End Sub

JonPeltier
08-21-2005, 08:04 PM
I've posted a response to this same query in one of the Microsoft news groups, I think the charting group, if anyone's interested.