Share via

Error 4142 Command Failed while inserting an inline shape in a Word Document from Excel VBA

Anonymous
2023-08-03T20:45:44+00:00

I've been using this piece of code to add an inline shape to a word document and within the last couple of weeks it stopped working.

myWDRange is a Word.Range

myPath = "http:... " fule file path

myFile = File Name

myWDRange.InlineShapes.AddOLEObject _

            ClassType:="Package", \_ 

            Filename:=myPath, \_ 

            LinkToFile:=False, \_ 

            DisplayAsIcon:=True, \_ 

            IconFileName:="C:\WINDOWS\system32\packager.dll", \_ 

            IconLabel:=myFile 

I then recorded saving attaching the inline shape in word and got this piece of code

wordapp.Selection.InlineShapes.AddOLEObject ClassType:="Word.Document.12", _

Filename:= (FULL FILE PATH) _

, LinkToFile:=False, DisplayAsIcon:=True, _

IconFileName:="C:\WINDOWS\Installer{90160000-000F-0000-1000-0000000FF1CE}\wordicon.exe" _

, IconIndex:=13, _

IconLabel:=filename

And I get the same darn error (from Excel). Can someone assist? I use this piece of code ALL THE TIME.

Microsoft 365 and Office | Word | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Anonymous
    2023-08-05T13:01:25+00:00

    Could you share us a screenshot of that error message? It will help to reproduce your issue and narrow down the cause.

    The situation you mentioned is related to VBA code, you can refer to this article: Office VBA support and feedback | Microsoft Docs to go to Stack Overflow by using the VBA tag, along with any other relevant tags as there are also many experienced engineers and experts in the forums there.

    Was this answer helpful?

    0 comments No comments