To read a document property for a closed Excel file, the code below can be used. Test by creating an Excel file "MyExcelFile.xlsx" in C drive.
Is there an equivalent method for a Word document?
Please Login or Register to view this content.
To read a document property for a closed Excel file, the code below can be used. Test by creating an Excel file "MyExcelFile.xlsx" in C drive.
Is there an equivalent method for a Word document?
Please Login or Register to view this content.
You're not really reading a property of a closed file if you open it. Word Document objects have the same properties, so
although you can read saved time of a file without opening using filedatetimePlease Login or Register to view this content.
Please Login or Register to view this content.
Don
Please remember to mark your thread 'Solved' when appropriate.
I'm getting an error when I use the first module in #2:
Run-time error '-2147467259 (80004005)':
Automation error
Unspecified error
With the second method, it does work ... however I need to also extend to other properties such as Title and Subject, which I think cannot be done this way?
The longer version of #2
Please Login or Register to view this content.
I still get the same error message.
You can tell the file is opened as you can see the lighter colored "~$WordFile.docx". This has to be opened and closed manually to try again.
If I replace MsgBox odoc.BuiltinDocumentProperties("Last save time") with MsgBox FileDateTime("C:\MyWordFile.docx"), it will work.
Is your Word application working normally if you run it manually?
Yes, it is working normally as far as I know.
Last edited by Un-Do Re-Do; 01-30-2018 at 11:35 AM.
I will try in another computer tomorrow.
@xlnitwit, I made just one small change to the code in post #4.
set odoc = oword.documents.open("C:\MyWordFile.docx") is changed to Set oDoc = oWord.Documents.Open(FileName:="C:\MyWordFile.docx")
This seems to work now.
Thanks for your help.
Please Login or Register to view this content.
That is curious indeed. There should never be a need to use named arguments.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks