Results 1 to 3 of 3
  • Thread Tools
  1. New Lounger
    Join Date
    Mar 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have Word VBA code that builds a document from several other documents. It works fine for Word documents but fails when it goes to process an Excel spreadsheet. It fails in the following code even though the Excel workbook exists in the specified locationand and the range pointed to by the "Range_Information" variable exist in the workbook.

    Selection.InsertFile Filename:=DocPath & Input_File_Name & "." & Current_File_type, _
    Range:=Range_Information, ConfirmConversions:=False, Link:=False, Attachment:=False

    It fails with the following error message and when it fails, the cursor is at the end of the following line.

    Run-Time error 5101: This bookmark does not exist

    I have references to Visual Basic for Application, Microsoft Word 11 Object Library, Normal, OLE Automation, and Microsoft Excel 11 Object Library. This seems to have coincided with our recent upgrade to Office 2003.

    I would appreciate any suggestions that you may offer.

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 13 Times in 13 Posts
    This is a bug in Word 2003 and it appears to exist in Word 2007 too. I found a suggestion to use a named range instead of a cell reference but that doesn't work for me either.
    I fear you'll have to find an alternative for InsertFile, e.g. copy and paste.

  4. New Lounger
    Join Date
    Mar 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='BobGreer' post='767047' date='24-Mar-2009 12:19']I have Word VBA code that builds a document from several other documents. It works fine for Word documents but fails when it goes to process an Excel spreadsheet. It fails in the following code even though the Excel workbook exists in the specified locationand and the range pointed to by the "Range_Information" variable exist in the workbook.

    Selection.InsertFile Filename:=DocPath & Input_File_Name & "." & Current_File_type, _
    Range:=Range_Information, ConfirmConversions:=False, Link:=False, Attachment:=False

    It fails with the following error message and when it fails, the cursor is at the end of the following line.

    Run-Time error 5101: This bookmark does not exist

    I have references to Visual Basic for Application, Microsoft Word 11 Object Library, Normal, OLE Automation, and Microsoft Excel 11 Object Library. This seems to have coincided with our recent upgrade to Office 2003.

    I would appreciate any suggestions that you may offer.[/quote]
    Thanks everyone for your suggestions. The fix or workaround was to use the copy and paste methods. I added an IF statement to determine that we were processing an Excel spreadsheet, if so, I call a procedure that opens the workbook and copies the cell range into the Word document.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •