(Solved) – VBA code designed to open multiple documents and edit them, but I can’t get it to open any documents


I’m making a VBA program with two Subs, the first to open all documents in a given folder and then call the second Sub, and the second to actually perform the editing. For some reason though, I can’t seem to actually open the folder I’m trying to open. The second Sub works fine (based on testing in single documents) but I can’t seem to figure out why the first doesn’t. The code is

Sub documentManagerToEditAllDocuments()
Dim file
Dim directoryPath As String

directoryPath = InputBox("What folder would you like to use?")

file = Dir(directoryPath & "*.doc*")
Do While file <> ""
Documents.Open FileName:=directoryPath & file

Call documentEditorForOneDocument


file = Dir()
End Sub

I’ve tried using a message box after calling the second Sub, but the program doesn’t get far enough to run it. If it helps, I’m using an administrator account and accessing folders inside my documents folder in the C:UsersOwnerDocuments location.
Thanks for the help

Leave a Reply

Your email address will not be published. Required fields are marked *