A family of Microsoft word processing software products for creating web, email, and print documents.
Great news. The 2302 patch just came out, tested it on a couple computers here and the InsertFile function is now working properly.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
We have a product that assembles custom templates that has been around for about 20 years that operates on a library of about 1 million Word .docx format templates. With users across the world. Its been in use on every version of Word since 2003 (currently only supported on all versions of Office 365 but it also still works on Word 2010). We use the Word VBA function InsertFile to append pages together to create custom documents from the template library.
Recently all of our installations started failing with the InsertFile function returning error 5097 - "Word has encountered a problem". And customers have started reporting the same error.
We traced it down to being introduced in the Aug 3 Build of Word and verified it on multiple computers (both Windows 10 and Windows 11). If we roll back our Word builds through the last 7 builds we found that in every case the June 14, June 29, July 6, July 18 builds of Word work fine. But all 3 builds after that which are Aug 3, Aug 9 and the current Aug 31 fail.
Something appears to have been recently broken by Microsoft in the Aug 3 Build that causes the Word's InsertFile function to fail. This happens on almost all of our Word .docx template we have tested. But when inserting the file via the Word toolbar's Insert > Text From File > browse to the file it works. But it always fails now when calling the InsertFile function via VBA. Again, this is not a new macro or templates. This code has been in use for almost 2 decades and the templates have been in use for for many years. Its only since the recent builds of Word in the last month that installations are now starting to fail everywhere.
This zip file linked below contains the macro vba test function and some example files to reproduce the problem.
When we save those templates that are failing to insert as legacy Word 2003-2007 .doc files they do insert without failing. And if we save them in Word 2003-2007 XML or as an OpenDocument .odt file they insert correctly. But if we save them as Word XML .xml or Strict Word XML .xml they also fail. So there is nothing corrupt in the files, it appears to be inserting current format files of various file formats are failing, but saving those failing files as legacy formats they insert correctly.
How do we submit this problem to Microsoft's Office 365 team as a bug report? This is a serious problem that breaks our product and requires us to have everyone roll back their Office 365 to the July 18, 2022 build and we're in the process of having to update our product to provide instructions when the error occurs on how to roll back Office 365.
The code in the test script is also here. But it needs the .docx files from the ZIP file to operate on.
Sub InsertTest()
Dim DocRng As Range
Dim FileToInsert As String
Dim SourceFile As String
Dim MsgStr As String
Dim MsgResult As Long
On Error GoTo ErrHandler
SourceFile = "c:\temp\CoverLetter.docx"
FileToInsert = "c:\temp\ExecSummaryA.docx" ' This file fails to insert
' FileToInsert = "c:\temp\ExecSummaryB.doc" ' This file works (this was the ExecSummaryA.docx Saved As a .doc file in Word 2003-2007 format)
' FileToInsert = "c:\temp\AccessoriesA.docx" ' This file fails to insert
' FileToInsert = "c:\temp\AccessoriesB.doc" ' This file works (this was the AccessoriesA.docx Saved As a .doc file in Word 2003-2007 format)
Documents.Open FileName:=SourceFile
ActiveWindow.ActivePane.View.Type = wdPrintView
Set DocRng = ActiveDocument.Content
DocRng.Collapse (wdCollapseEnd)
DocRng.InsertFile FileName:=FileToInsert, Range:="", ConfirmConversions:=False, Link:=False, Attachment:=False
Exit Sub
ErrHandler:
MsgStr = "Error: " & Err.Number & " - " & Err.Description
MsgResult = MsgBox(MsgStr, vbSystemModal + vbMsgBoxSetForeground, "Insert Error")
End Sub
A family of Microsoft word processing software products for creating web, email, and print documents.
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.
Great news. The 2302 patch just came out, tested it on a couple computers here and the InsertFile function is now working properly.
I'll double check with the companies having the problem which channel/plan they have and OS version. But it is happening on both Windows 10 and Windows 11. I have multiple Windows 10 and multiple Windows 11 PCs its failing on and one of the last customers I talked with was running Windows 10.
And only to people using the Current Channel builds that I can recall and also I think more than one person on a couple of these threads I've posted said it worked on their Enterprise install of Office but failed on their Current Channel. All my PCs that are failing are running the Current Channel builds.
As far as I know its supposed to be the same version of Word that people get regardless of the plans. And my understanding is that the Enterprise version is just a licensing difference for # of users. And Current Channel vs Monthly Enterprise or Semi-Annual Enterprise is just the frequency of updates.
So if I were to get a support plan what plan would get me access to a real developer who can find an real answer such as seeing what is in the files that is causing InsertFile to fail or running the test that's replicating it in a debugger that will tell them why InsertFiles is failing (and hopefully be able to propose a fix on their end) or in the least tell me why the files are failing. So many plans on the MSFT web site. Just need something like a single issue plan that doesn't get me a support rep in a data center who's just reading from a script.
Doug - do bribes work?
I have no idea who you would have to bribe.
Another issue that complicates the matter is with the latest update - Version 2209 (Build 15629.20156 Click-to-Run) Current Channel of 64-bit Microsoft 365 Apps for enterprise, there is no problem with the InsertFile command where used on a computer running Windows 10, while here, there is a problem when the computer is running Windows 11.
In addition, the docx files insert without issue when using Version 2209 (Build 15629.20156 Click-to-Run) Current Channel of 64-bit Microsoft Office Professional Plus 2021 on a machine running Windows 10
So, the question is: Is it a Word issue or a Windows issue?
Doug - do bribes work? If you want to pass along to the 365 team I'll give someone foil surfing lessons in exchange for helping me out. Seriously - I live a few blocks from Microsoft campus in Redmond on the lake. Already taught my neighbor who works there how to foil surf.
Also, you just gave me another idea for a workaround I can try adding. Instead of copy/paste from the templates that are failing maybe I can make a new temporary document and copy/paste from the failing .docx files into a new file copying the body content, headers and footers. Then import the temporary newly created .docx. Then I can look into adding a library rebuild tool that can run through all 2200 templates each customer has and rebuild them using the create new doc and copy/paste.
Still doesn't solve the problem for half the people, but if it resolves the problems with some background graphics and footer problems using the other temporary workarounds it will help.
Nope, never had a need for support plans. I'm more than willing to work on the problem with someone, but not going to buy a support plan for it if its someone elses stuff that broke.