Hello
First time on here, so if I'm doing anything I shouldn't, please be kind and just let me know.
I'm a trainee and in one of my exercises is the following task:
(a) write a macro that uses a For loop to do this – if the document name begins with the word “Document” then close that document.
(b) can you write the code so that the client is not prompted to save every time one of the documents is closed?
I have tried doc.Close (wdDoNotSaveChanges) but this still brings up the prompt to save for each document.
Code
Dim doc As Document
Dim strName As String
Set doc = ActiveDocument
For Each doc In Documents
strName = InStr(doc.Name, "Document") 'I know this bit is technically wrong as it returns a "1" for true, just need to figure out how to change it to return a string
If strName = True Then
Application.DisplayAlerts = False
doc.Close SaveChanges:=False
End If
Next doc
Display More
I look forward to hearing from you as I am well and truly stumped!
Many thanks
Deb