Consulting

Results 1 to 5 of 5

Thread: VBA Error when inserting file into Word

  1. #1

    VBA Error when inserting file into Word

    Hi All,

    I now use Excel 2010 and have been getting a error message when running a piece of code:

    [vba]wdDoc.Activate

    Set t = wdDoc.Bookmarks("Section10_File").Range

    t.InlineShapes.AddOLEObject ClassType:="Excel.Sheet.12", Filename:= _
    GlobalFolder & "Device Compliance Audit.xlsx" _
    , LinkToFile:=False, DisplayAsIcon:=True, IconFileName:= _
    "C:\WINDOWS\Installer\{90120409-6000-11D3-8CFE-0150048383C9}\xlicons.exe" _
    , IconIndex:=1, IconLabel:="Section 10 Data"
    [/vba]

    The Error message is:

    "The program used to create this object is Excel. That program is either not installed on your computer or it is not responding. To edit this object, install Excel or ensure that any dialog boxes in Excel are closed"

    When the error appears I have to click OK. I then get a the debug error message:

    Run-time error '4198': Command Failed

    When I then press debug the following is highlighted:

    [vba]t.InlineShapes.AddOLEObject ClassType:="Excel.Sheet.12", Filename:= _
    GlobalFolder & "Device Compliance Audit.xlsx" _
    , LinkToFile:=False, DisplayAsIcon:=True, IconFileName:= _
    "C:\WINDOWS\Installer\{90120409-6000-11D3-8CFE-0150048383C9}\xlicons.exe" _
    , IconIndex:=1, IconLabel:="Section 10 Data"[/vba]

    If I then press the Continue Button (F5) without any amendments the rest of the code runs through to completion even though I have 3 other identical pieces of code (to insert files) that run through without any other errors.

    So my issue is why this error message presents itself/what can be done to stop this from happening. If it cant is there any other way to insert files into my word document?

    many thanks in advance.

    Paddy.

  2. #2
    Bump.

  3. #3
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Just a stab, try changing ClassType:="Excel.Sheet.12" to 14, as I think that is what 2010 is.

    If that doesn't work, I'd suggest attaching a workbook and document (zipped) to replicate the error.

    Mark

  4. #4
    changing to Excel.sheet.14 has no effect on the error. I have other excel files in the script that attach (they are excel.sheet.8) without a problem.

  5. #5
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Are you sure that the path to the xlicons.exe exists?

    On my winxp excel 2010 the path is:
    C:\WINDOWS\Installer\{90140000-0011-0000-0000-0000000FF1CE}\xlicons.exe

Posting Permissions

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