Add an Excel Range into Word

F

Francisco

Hi,
I try to keep it simple.
By using VBA, I try to link a Range within Excel ("MyRange") into a Text box
("MyTextbox") in Word. I currently use 2003.

I am using: "InlineShapes.AddOLEObject" method, but it does not seem to work.
What is the correct syntax?
Any suggestion?
Thanks
Francisco
 
J

Jean-Guy Marcil

Francisco was telling us:
Francisco nous racontait que :
Hi,
I try to keep it simple.
By using VBA, I try to link a Range within Excel ("MyRange") into a
Text box ("MyTextbox") in Word. I currently use 2003.

I am using: "InlineShapes.AddOLEObject" method, but it does not seem
to work. What is the correct syntax?
Any suggestion?
Thanks
Francisco

To insert an Excel file in a textbox, put a bookmark n that textbox (Hee
called "Test") and try this:

With ActiveDocument
.InlineShapes.AddOLEObject ClassType:="Excel.Sheet.8", _
FileName:="C:\Book1.xls", LinkToFile:=True, _
DisplayAsIcon:=False, Range:=.Bookmarks("Test").Range
End With

Or, to specify a range in Excel; here from A1 (Row1Column1 - R1C1) to C6
(Row6Column3 - R6C3) on "Sheet1":

With ActiveDocument
.InlineShapes.AddOLEObject ClassType:="Excel.Sheet.8", _
FileName:="C:\Book1.xls!Sheet1!R1C1:R6C3", LinkToFile:=True, _
DisplayAsIcon:=False, Range:=.Bookmarks("Test").Range
End With

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
F

Francisco

Jean,
Spot on!!!
The key was FileName:="C:\Book1.xls!Sheet1!R1C1:R6C3",
I use ranges rather than cells.
Thanks a lot.
 

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