VBA & Macro Problems

Fix Word VBA Error 5174 When Reopening a SharePoint Document

Anum MushtaqAnum Mushtaq Nov 22, 2026 868 views

Question details

Reopen a SharePoint document after saving and closing it with a Word VBA macro.

Fix Word VBA Error 5174 When Reopening a SharePoint Document
Product
Microsoft Word VBA and SharePoint
Device & OS
not provided
Scenario
A macro saves, closes, and reopens a Word document stored in SharePoint.
Observed behavior
The macro may show run-time error 5174, stop when its host document closes, or briefly display a blank screen.
Before you start

Open the intended SharePoint document in Word and check whether the macro is stored in that document, a template, or an add-in. Make sure you have access to the document's SharePoint location.

Solution 1Recommended

Save the document path and reopen it from a template or add-in

Use the document's full path as a variable and keep the running macro outside the document being closed.

1
Move the macro if necessary

Press Alt+F11 to open the VBA editor. If the macro is stored in the document it closes, move it to a template or add-in that remains open.

2
Capture the active document

In the VBA editor, set a Document variable to ActiveDocument and save its FullName before closing it. ThisDocument refers to the template or add-in when the macro is stored there, not necessarily the SharePoint document.

3
Save, close, and reopen

Use the saved variable without quotation marks in Documents.Open. For example: Sub ReopenSharePointDocument() Dim doc As Document Dim strPath As String Set doc = ActiveDocument strPath = doc.FullName doc.Save doc.Close SaveChanges:=wdDoNotSaveChanges Documents.Open FileName:=strPath End Sub

4
Run the macro

Activate the intended SharePoint document in Word, then run the macro from Developer > Macros. If error 5174 persists, check that the saved path is accessible and points to the intended document.

Save the document path and reopen it from a template or add-in
About the blank screen: Setting Application.ScreenUpdating to False during the operation may reduce screen updates, but it may not prevent a blank display. Restore it to True afterward, including if an error occurs. Reopening time depends on document size and connection speed.
Free Microsoft Office alternative

Edit Word Documents with WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for opening and editing Word files. Its format compatibility helps you move existing documents into WPS, although it does not fix Microsoft Word VBA errors.

Open and edit Microsoft Word DOC and DOCX filesUse a familiar interface for document editingWork with existing Word documents when moving to WPSUse a free, lightweight office suite
microsoft office alternative - wps office

Frequently Asked Questions

Why does Documents.Open("strPath") cause error 5174?

The quotation marks make strPath literal text rather than the variable's value. Use Documents.Open FileName:=strPath to pass the saved path.

Should I use ThisDocument or ActiveDocument?

ThisDocument refers to the document or template containing the macro. If the macro is in a template or add-in, use ActiveDocument to identify the document being edited, and capture its FullName before closing it.

Why does the macro stop after closing the document?

If the running macro is stored in the document being closed, closing that document can stop execution. Move the macro to a template or add-in that remains open.

Can I prevent the screen from going blank while Word reopens the file?

Application.ScreenUpdating = False may reduce screen updates, but it does not guarantee a blank screen will disappear. Set it back to True after the operation, including in error handling.