Jay
Sun Dec 02 14:47:47 PST 2007
On Sun, 2 Dec 2007 13:21:01 -0800, Garth M
<GarthM@discussions.microsoft.com> wrote:
>Hi there,
>
>I'm merging word documents into a word doc report using selection.insertfile
>command. I also want to insert excel files as ole objects nto the word
>report. How do I go about it?
>
>Thanks
>Garth
If you want it positioned inline with text, use this kind of code:
Sub demo()
Dim path As String
Dim Ils As InlineShape
path = "C:\temp\somefile.xls"
Set Ils = ActiveDocument.InlineShapes.AddOLEObject( _
FileName:=path, LinkToFile:=False, _
DisplayAsIcon:=False, Range:=Selection.Range)
End Sub
If you want it to float, you need something different:
Sub demo()
Dim path As String
Dim Shp As Shape
path = "C:\temp\somefile.xls"
Set Shp = ActiveDocument.Shapes.AddOLEObject( _
FileName:=path, LinkToFile:=False, _
DisplayAsIcon:=False, Anchor:=Selection.Range)
With Shp
.WrapFormat.Type = wdWrapSquare
.RelativeHorizontalPosition = _
wdRelativeHorizontalPositionMargin
.RelativeVerticalPosition = _
wdRelativeVerticalPositionParagraph
.Left = InchesToPoints(1.5)
.Top = InchesToPoints(0.25)
End With
End Sub
There are other parameters you can set, but this gives you the flavor
of the technique.
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ:
http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.