Something that used to be very easy: in Excel VBA, open Word document as ReadOnly file, do something, close Word doc, move to the next Word doc.
So, I have this code in Excel (with the Reference to Word):
But no matter what I try, Word wants me to Save file
Even when I said: do not display any alerts (see code)
Even outside VBA, when I just open Word and just look at it, and close it - Word asks me to save it.
What am I doing wrong?
(Excel 365 Apps for Enterprise Version 2408, if that helps)
So, I have this code in Excel (with the Reference to Word):
Code:
Option Explicit
Sub OpenWordDocs()
Dim wdApp As New Word.Application
Dim wdDoc As New Word.Document
Dim strPath As String
Dim strFile As String
'strPath = GetFolder & "\"
strPath = "C:\Temp\"
wdApp.DisplayAlerts = wdAlertsNone
wdApp.Visible = True
strFile = Dir(strPath & "*.docx")
Do While strFile <> ""
Debug.Print strFile
Set wdDoc = wdApp.Documents.Open(strPath & "\" & strFile, ReadOnly:=True)
Debug.Print strFile & " has " & wdDoc.Paragraphs.Count & " Paragraphs"
wdDoc.Close
strFile = Dir()
Loop
wdApp.Quit
Set wdApp = Nothing
End Sub
But no matter what I try, Word wants me to Save file
Even when I said: do not display any alerts (see code)
Even outside VBA, when I just open Word and just look at it, and close it - Word asks me to save it.
What am I doing wrong?
(Excel 365 Apps for Enterprise Version 2408, if that helps)