Microsoft KB Archive/224699

= WD2000: Cannot Insert File Using Named Range of Excel File =

Article ID: 224699

Article Last Modified on 6/17/2005

-

APPLIES TO


 * Microsoft Word 2000 Standard Edition

-



This article was previously published under Q224699



SYMPTOMS
When you attempt to insert a named range from a Microsoft Excel file, you receive the following error message:

The document name or path is not valid. Try these suggestions.


 * Check the file permissions for the document or drive.


 * Use the File Open dialog box to locate the document.

NOTE: This problem occurs when you click File on the Insert menu, click the Excel file you want to insert, click the Range button to specify the named range, click OK, and then click Insert.



WORKAROUND
To work around this problem, use either of the following methods.

Method 1: Insert as a Database File
When you want to insert a named range contained in an Excel file into Microsoft Word, follow these steps:
 * 1) On the View menu, point to Toolbars and click Database.
 * 2) On the Database toolbar, click Insert Database.
 * 3) In the Database dialog box, click Get Data.
 * 4) In the Open Data Source dialog box, change the Files of type box to MS Excel Worksheets (*.xls) and click to select your Excel file.

NOTE: You may need to change the Look in box to the folder that contains your Excel worksheet.
 * 1) In the Open Data Source dialog box, select the Select method check box, and then click Open.
 * 2) In the Confirm Data Source dialog box, click Excel sheets via ODBC (*.xls) and then click OK.
 * 3) In the Select Table dialog box, click the table (named range) you want that is contained in your Excel worksheet, and click OK.
 * 4) In the Database dialog box, click Insert Data.
 * 5) In the Insert Data dialog box, click the range of records that you want to insert, and click OK.

For example, if you want to use all of the records contained in the named range, click All.

Word inserts the records contained in the named range of your Excel worksheet as a table into your Word document.

Method 2: Use a Macro Solution
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

Create and run a macro similar to the following example to insert the named range from your Microsoft Excel worksheet: Sub Macro1

Selection.Range.InsertDatabase Format:=0, Style:=0, _ LinkToSource:=False, Connection:= "DSN=Excel Files; _  DBQ=C:\ExcelTest.xls;DriverId=790;MaxBufferSize=2048;PageTimeout=5;", _ SQLStatement:="SELECT * FROM `TheRange`" & "", PasswordDocument:="", _ PasswordTemplate:="", WritePasswordDocument:="", _ WritePasswordTemplate:= "", DataSource:="C:\ExcelTest.xls", _ From:=-1, To:=-1, IncludeFields:=True

End Sub For more information about how to use the sample code in this article, click the article number below to view the article in the Microsoft Knowledge Base:

212536 OFF2000: How to Run Sample Code from Knowledge Base Articles



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

