Hello and help
Word 2007, I need to copy a named range from a closed Excel file, then paste
special it as a Paste Link - Microsoft Office Excel Worksheet Object in to
the active Word document.
So far I have the following code which copies the whole Excel sheet ,
Dim FileName As String
FileName = "c:\\Test.688.xls"
FileName = "LINK Excel.Sheet.12 """ & FileName & """ \a "
Selection.TypeText FileName
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
FileName, _
PreserveFormatting:=True
But I need to restrict this to a named range.
Any ideas or pointers
Thanks
Cresta - 05 Oct 2007 15:01 GMT
Found it, anyone interested here is the code
> Dim FileName As String
> FileName ="c:\\ExcelFile.xls" & """ """ & "Sheet1!NamedRange"""
[quoted text clipped - 3 lines]
> FileName, _
> PreserveFormatting:=True
> Hello and help
> Word 2007, I need to copy a named range from a closed Excel file, then paste
[quoted text clipped - 15 lines]
>
> Thanks
Jean-Guy Marcil - 05 Oct 2007 15:32 GMT
Cresta was telling us:
Cresta nous racontait que :
> Hello and help
> Word 2007, I need to copy a named range from a closed Excel file,
[quoted text clipped - 15 lines]
>
> Thanks
Add a statement under
FileName = "c:\\Test.688.xls"
for the named range:
SheetName = "SheetName!NamedRangeName"
Then change the second FileName statement from
FileName = "LINK Excel.Sheet.12 """ & FileName & """ \a "
to
FileName = "LINK Excel.Sheet.12 """ & FileName & """ """ & SheetName &
""" \a "
By the way, why do you use
Selection.TypeText FileName
?
Do you need to see the field code in the document, but outside the field
istelf?

Signature
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org
Cresta - 05 Oct 2007 15:50 GMT
Thanks for you help, that works fine.
> Cresta was telling us:
> Cresta nous racontait que :
[quoted text clipped - 35 lines]
> Do you need to see the field code in the document, but outside the field
> istelf?